Conditional resource inclusion/exclusion for Android apk build

感情迁移 提交于 2019-12-04 04:37:39

1 - Base library project has localization files for en, es, etc.

You have two projects using this library, and only one of them needs all the translations. Hence, those translations could be in the project using the library and needing the translations, not in the library itself. This is no different than any other project customizing resources of a library (e.g., replacing icons, replacing layouts).

Now, once you start getting into more complicated mixes (e.g., two projects need the translations and a third does not), then you start running into problems.

Exclusion of build-specific resources. I have a few images that are only needed for my Nook-specific builds of my apps, which are triggered by a flag. Conditional code works great, but the resources are always included.

Xav and I chatted a bit about conditional resources in this issue. His focus is on debug vs. production (resource equivalent to BuildConfig.DEBUG), but it sounds like something more flexible is a possibility.

Both of these things could be handled by a custom release build script. In normal debug builds, you'd leave it all alone; in a production build, have an Ant script work off a copy of the project, trimming out directories that are not needed, before compiling, signing, and zipaligning.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!