【问题标题】:Notification icon missing with ProGuard enabled启用 ProGuard 时缺少通知图标
【发布时间】:2016-11-23 09:55:49
【问题描述】:

启用 ProGuard 后,我们的推送通知图标 (res/drawable-*/ic_notifications.png) 不见了(只显示了一个空圆圈,其颜色为 notificationAccentColor)。

图标仅来自 Urban Airship 配置文件 (airshipconfig.properties):

notificationIcon = ic_notifications
notificationAccentColor = #0000CC

我怀疑 ProGuard 认为该图标未使用,并将其删除。有什么方法可以告诉 ProGuard 保留它?

【问题讨论】:

  • 必须在另一个具有不同操作系统版本的手机中检查这个,我怀疑这不是与 proGaurd 相关的问题,这个问题可能是 ic_notification 不是更高版本所需的格式

标签: android android-gradle-plugin android-resources urbanairship.com


【解决方案1】:

ProGuard 不会删除资源。我怀疑你使用了 Android gradle 插件的shrinkResources 功能?请查看以下页面,该页面描述了如何防止某些资源被压缩:https://developer.android.com/studio/build/shrink-code.htmlCustomize which resources to keep 部分)。

【讨论】:

  • 确实,你是对的。我们在启用 ProGuard 的同时引入了shrinkResources true,因此造成了混乱。
  • 我们案例中的完整解决方案:在新文件res/values/keep.xml 中添加<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@drawable/ic_notifications"/>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-17
  • 2011-12-29
  • 2017-12-01
  • 2013-09-18
相关资源
最近更新 更多