背景
今天偶然发现release版本的包上出现图片无法显示的问题,之前在debug版一直没有出现,因为用的SDK需要把图片资源放到drawable下,分析了下apk包,发现相应的图片资源没有被打包进来,起初认为是混淆的原因,但是混淆只是针对代码,后发现了这个配置shrinkResources true
介绍
“resource shrinking”: the automatic removal of resources that are unused, at build time, in the packaged app. In addition to removing resources in your project that are not actually needed at runtime, this also removes resources from libraries you are depending on if they are not actually needed by your application.
以上是官方说明,大概意思是在应用构建打包的过程中自动删除没有引用的资源,对依赖的库同样有效
使用
Note that resource shrinking only works in conjunction with code shrinking (such as ProGuard).That’s how it can remove unused resources from libraries; normally, all resources in a library are used, and it is only when we remove unused code that it be