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.
android.applicationVariants.all { variant -> variant.resValue "color", "colorPrimary", "#" + theme.colorPrimary }
variant has properties that you need(like fx variant.name) ... put this into build.gradle without "parent" (fx.: at the end of file) – Hanes