I want to have 3 product flavors, and one of them will have less language support than Main. For example, only support /values-fr. Is there a filter function in Gradle? Thanks.
Asked
Active
Viewed 2,890 times
6
-
Take a look at this question - http://stackoverflow.com/questions/31566270/force-locale-for-android-flavor-with-resconfig – Oleksandr Feb 23 '16 at 11:57
1 Answers
6
From Android Gradle Build System, since version 0.7.0:
- New option on product Flavor (and defaultConfig) allow filtering of resources through the -c option of aapt
- You can pass single value (resConfig) or multiple values (resConfigs) through the DSL.
- All values from the default config and flavors get combined and passed to aapt.
- See "basic" sample.
In the "basic" sample:
defaultConfig {
...
resConfig "en"
resConfigs "nodpi", "hdpi"
}
So, try the following to achieve what you asked for:
productFlavors {
...
frOnly {
resConfig "fr"
}
...
}
Note that you might also want to include *dpi, port, land, etc.. as well

Ladios Jonquil
- 1,576
- 1
- 9
- 4
-
Actually, it doesn't work, as expected. See this question to more information - http://stackoverflow.com/questions/31566270/force-locale-for-android-flavor-with-resconfig – Oleksandr Feb 23 '16 at 11:57