Gradle always take the values from the buildType inside the last flavor
You can have work arounds like: defining string values at the build time which you can reference in any part of the code. Here is an example that may help you or anybody else
buildTypes { production { minifyEnabled true signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } development { minifyEnabled false }}productFlavors { mcDonalds { resValue "string", "key1", "value1" resValue "string", "key2", "value2" } burgerKing { resValue "string", "key1", "value1" resValue "string", "key2", "value2" }
}
This will create the following build variants with different configs
- mcDonaldsDevelopment
- mcDonaldsProduction
- burgerKingDevelopment
- burgerKingProduction
also in your code you can check if you are production of development using the following
if (BuildConfig.DEBUG) { //select string for development (key1) } else { //select string for production (key2) }