我有一个共享库,由应用程序的多个方差使用。我希望能够根据应用配置删除未使用的库资源。
我正在使用ant构建脚本向hackery移除它以从库jar中删除它。还有其他想法吗?
答案 0 :(得分:0)
找到我的解决方案,使用属性aapt.ignore.assets删除最终apk中我不想要的内容。剪辑自sdk r22 tools / ant / build.xml
<!-- 'aapt.ignore.assets' is the list of file patterns to ignore under /res and /assets.
Default is "!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
Overall patterns syntax is:
[!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns...
- The first character flag ! avoids printing a warning.
- Pattern can have the flag "<dir>" to match only directories
or "<file>" to match only files. Default is to match both.
- Match is not case-sensitive.
-->
<property name="aapt.ignore.assets" value="" />
此属性的意外副作用是它在“code-gen”期间也会被使用,并且不会生成drawable id并且proguard会抱怨。您需要在配置中添加dontwarn。
您还希望将这些资源包装到自己的类中,当资源不在时,不会调用它们。因为如果它们在一个公共类中,即使没有使用,java静态初始化程序也会崩溃,试图将它们链接起来。
答案 1 :(得分:0)
此排除来自.apk 版本的整个./www/app
目录:
<property name="aapt.ignore.assets" value="<dir>app:" />