I was trying to do white labeling for my app but I am stuck at a point where I need to use configuration based on buildType + flavor combination.
i.e let’s assume I have 2 buildTypes (debug & release) and 2 flavors (flavor1 & flavor2), I would like to use 4 different keys based on the combination as follows:
- flavor1 + debug = key1
- flavor1 + release = key2
- flavor2 + debug = key3
- flavor2 + release = key4
how do I achieve the same?
below is my build.gradle file.
buildTypes {
getByName("debug") {
applicationIdSuffix = ".debug"
versionNameSuffix = ".debug"
buildConfigField("boolean", "DEBUG_MODE", "true")
}
getByName("release") {
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
buildConfigField("boolean", "DEBUG_MODE", "false")
}
}
flavorDimensions("version")
productFlavors {
create("flavor1") {
setDimension("version")
}
create("flavor2") {
setDimension("version")
versionCode = 1
versionName = "1.0"
}
}