btw have anyone ever used gradle flavors to swap s...
# android-architecture
u
btw have anyone ever used gradle flavors to swap string resources like app name? the issue is I have 3 flavor dimensions, and want to AND 1st and 3rd, and it doesnt seem to work, only if I add the 2nd inbetween, however then I multiply it by all 2nd dimension's values which is stupid, I must be missing something
j
The whole point of having flavor dimensions is that you need to include all of them. perhaps if you post the flavors and what you want to achieve, perhaps it can be improved. Perhaps you can solve some of your problems with different build types
u
api = tst, ppt, prod faceRecoIncluded = faceReco, noFaceReco stability = stable, dev
and I want to rename apps for api x stability
j
What does the stability flavor do?
sounds like debug/release build types
but anyway, you can change values like:
Copy code
android {

	defaultConfig {
        resValue 'string', 'app_name', 'App'
    }

    applicationVariants.all { variant ->
        def names = variant.productFlavors*.name
        if (names.contains("tst")) { // Only overrides it for any variant using tst flavor
            variant.resValue 'string', 'app_name', 'App Test'
        }
    }
}
Or you could simply change suffix of the app name:
Copy code
android {

	defaultConfig {
        manifestPlaceholders.appName = "App"
        manifestPlaceholders.appNameSuffix = ""
    }
    applicationVariants.all { variant ->
        def names = variant.productFlavors*.name
        if (names.contains("tst")) {
            variant.mergedFlavor.manifestPlaceholders.appNameSuffix = ' Test'
        }
    }

}
And then in manifest:
Copy code
<manifest>
    <application
        android:label="${appName}${appNameSuffix}">
    //....
    </application>
</manifest>
u
Yes thats my plan B. However turns I need some other resources as well, not just the name 😔 (some licence files, and that painful to included hardcoded like that from gradle)
j
Well whatever I wrote can be used for other things as well, you can also adjust buildconfig things with it
u
okay thanks however im still perplexed I cannot do it via the resource folders is the only kosher solution to have all the combinations folders?
j
Oh you can also do that
Make a folder called as your flavor and place it next to main
u
Thats the whole issue, that I want to combine two flavors into a fooBar folder but it doesnt work, since in reality its 3 flavors, so only fooQuaxBar works