My other answer about the generated resources may be an overkill for you use case though. Base what I currently know about your project I think this one is a better fit:
(not that you can still combine this with generated resources)
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/values-hu/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/values-hu/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 app_name_gpe
string resource, but that'll be taken care of by aapt:
android {
buildTypes {
release {
shrinkResources true // http://tools.android.com/tech-docs/new-build-system/resource-shrinking
}
strings.xml
solutions, but I don't think you can do it otherwise. If you have separation issues, you can add differentres.srcDir
s based what you're localizing, but the folder you add can contain multiplevalues-<lang>/strings.xml
files. – Upstreamsrc/main/res/values/strings.xml
andsrc/googlePlay/res/values/strings.xml
to add your localized, flavored strings how it would be intended? Even if you could just add it to the build script, the result would be the same as if you were just using those folders. – Coagulase