当我尝试缩小我的功能 APK 大小时,我在我的功能构建 Gradle 中使用 shrinkResources true
。
但是它提示 Error:Resource shrinker cannot be used for libraries.
这篇文章要求我们使用它 https://medium.com/jet-stories/make-your-app-instant-33855ab5d02b
是我做错了什么还是 Instant Apps 真的不支持?
最佳答案
据我从这篇文章中了解到(我只是快速阅读了它,仍在我的阅读列表中),shrinkResources true
只需要将 APK 大小减小 removing unused resources ,但这不是 Instant Apps 的正式要求。我猜工具链无法决定库中是否未使用资源,因为最终 APK 尚未构建。
因此,如果您的项目中没有未使用的资源,应该没有问题,可以将其删除。
然后,您的项目中可能存在一件事(我自己没有尝试过 Instant Apps,只是阅读并看到了 Google IO 演讲):据我了解,instant app 的所有模块都是 APK,而不是图书馆。因此,如果您将 shrinkResources true
应用到 APK,您就可以开始了。如果您的项目中有用于组装最终 APK 模块的库,请删除那里的 shrinkResources true
,并将其保留在模块中。
关于android - shrinkResources true 不能用于 Instant Apps 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46219987/