I have two product flavors and three build types.
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
qa {
applicationIdSuffix ".qa"
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
old {
applicationId "com.companyname.old"
buildConfigField "String", "contentProvider", '"com.companyname.android.mobile.contentprovider"'
resValue "string", "content_provider_authority", '"com.companyname.android.mobile.contentprovider"'
}
new {
applicationId "com.companyname.new"
buildConfigField "String", "contentProvider", '"' + applicationId + '.contentprovider"'
resValue "string", "content_provider_authority", '"' + applicationId + '.contentprovider"'
}
}
Is there a way I can change the resValue of content_provider_authority based not on product flavor, but for the variant? I want all builds for the product flavor new to use the application id + ".contentprovider" but for our product flavor old, use the hardcoded string if debug or release like shown above, but enhance it to have a different hardcoded string for qa build type.
This code is working for me, thanks to the comment of Selvin
productFlavors {
red {
ext {
googleMapsKey = [debug: "AIza4115643435", release: "AIzaXXXXXXXXXX"]
}
}
blue {
ext {
googleMapsKey = [debug: "AIza6363474341", release: "AIzaXXXXXXXXXX"]
}
}
applicationVariants.all { variant ->
def flavor = variant.productFlavors[0]
variant.resValue "string", "google_maps_key", "\"${flavor.ext.googleMapsKey[variant.buildType.name]}\""
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With