Can I exclude resource values from being built into my Android child project?
I have a couple of child Android projects that are linked to a base Android project. The base project includes various language directories 'values-xx'.
Is there a way to specifically exclude these dir开发者_如何学编程ectories from being built into the child projects?
i.e. A child project without the 'values-de' (German strings.)
I'm still looking for the best solution. Currently I split the languages out of my base lib into a language version (e.g. BaseLib and BaseLib-es). For apps that don't fully implement the other languages, I don't include the '-es' library project.
Unfortunately, when you have a big tree of base libraries or a lot of languages, this method creates a pile of extra library projects.
I think there needs to be a change to the APK export tool to solve this. Lint is smart enough to find incomplete translations, but I don't think ProGuard would be smart enough.
Even if this question is really old, you might never have found this so here it is. What you need is pretty much the new resConfig implemented in gradle build plugin 0.7 although I can't seem to be able to make it work like I understood it should.
from: http://tools.android.com/tech-docs/new-build-system/resource-shrinking#TOC-Res-Configs
Res Configs
In addition to removing unused resources, you can also use the Android Gradle plugin's "resConfigs" feature to have it remove any resource configurations that you app does not need.
For example, let's say the messages in your application have not been translated and are all in English. If you are using a library such as Google Play Services, you are picking up translations for all of the messages in those libraries. When functionality in the library is accessed, those will be shown to the user. Whether you prefer that, or want to have the whole app use a single language, is up to you. But if you choose to have a single language, or more generally, just the languages your app is targeting, you can set that up in your build.gradle file, and then at build time all other languages are dropped (which will make your APK smaller, similar to the resource shrinking facility).
Here's what you add to your build.gradle file if you for example want to limit your languages to just English and French:
android {
defaultConfig {
...
resConfigs "en", "fr"
}
}
You could also add resConfigs "nodpi", "hdpi" to for example also limit the density folders that are packaged, and in general you can use this facility to limit the bundled resources among any resource follder qualifier.
I have a similar problem Force locale for Android flavor with resConfig and still have not found why it is not working. I filed a bug in Android too.
精彩评论