My other answer about generated resources may be redundant for your use. Based on what I know about your project, I think it works better: (not that you can combine this with generated resources anyway)
Src / flavor1 / res / values / strings.xml
<string name="app_name_base">InTouch Messenger"</string> <string name="app_name_gpe">InTouch Messenger: GPE Edition"</string>
Src / flavor1 / res / x-value / strings.xml
<string name="app_name_base">InTouch Üzenetküldő"</string> <string name="app_name_gpe">InTouch Üzenetküldő: GPE Változat"</string>
Src / flavor2 / res / values / strings.xml
<string name="app_name_base">Whatever Messenger"</string> <string name="app_name_gpe">Whatever Messenger: GPE Edition"</string>
Src / flavor2 / res / x-value / strings.xml`
<string name="app_name_base">Whatever Üzenetküldő"</string> <string name="app_name_gpe">Whatever Üzenetküldő: GPE Változat"</string>
build.gradle
android { sourceSets { [flavor1, flavor3].each { it.res.srcDirs = ['src/flavor1/res'] } [flavor2, flavor4].each { it.res.srcDirs = ['src/flavor2/res'] } } productFlavors { // notice the different numbers than sourceSets [flavor1, flavor2].each { it.resValue "string", "app_name", "@string/app_name_base" } [flavor3, flavor4].each { it.resValue "string", "app_name", "@string/app_name_gpe" } } }
This means that flavor1/2 will have an extra unused line resource app_name_gpe , but aapt will take care of this:
android { buildTypes { release { shrinkResources true // http://tools.android.com/tech-docs/new-build-system/resource-shrinking }
TWiStErRob Mar 29 '16 at 10:37 2016-03-29 10:37
source share