https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
u

ursus

09/23/2020, 2:23 PM
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

Joost Klitsie

09/24/2020, 6:59 AM
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

ursus

10/02/2020, 10:55 PM
api = tst, ppt, prod faceRecoIncluded = faceReco, noFaceReco stability = stable, dev
and I want to rename apps for api x stability
j

Joost Klitsie

10/04/2020, 10:01 AM
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

ursus

10/04/2020, 1:20 PM
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

Joost Klitsie

10/04/2020, 1:26 PM
Well whatever I wrote can be used for other things as well, you can also adjust buildconfig things with it
u

ursus

10/06/2020, 5:08 PM
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

Joost Klitsie

10/06/2020, 5:18 PM
Oh you can also do that
Make a folder called as your flavor and place it next to main
u

ursus

10/07/2020, 5:42 AM
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
6 Views