flavorDimensions "app"
productFlavors {
dev {
resValue "string", "base_url", "http://mydevurl/"
dimension "app"
}
prod {
resValue "string", "base_url", "http://myprodurl/"
dimension "app"
}
}
applicationVariants.all { variant ->
def flavor = variant.mergedFlavor
def versionName
if (variant.buildType.isDebuggable()) {
versionName = "debug_0.1.1"
}else{
versionName = "0.1.1"
}
flavor.versionName = versionName
flavor.versionCode = 50
}
Above gradle setup was working fine till Gradle 3.0 update. Couldn't find anything related in the website referred. How to manage this dynamic version control based on this new flavorDimension
change?
You can dynamically set the versionCode and versionName with the 3.0 Android gradle plugin by using VariantOutput.setVersionCodeOverride() and VariantOutput.setVersionNameOverride().
For your project, this would look something like:
applicationVariants.all { variant ->
def flavor = variant.mergedFlavor
def versionName
if (variant.buildType.isDebuggable()) {
versionName = "debug_0.1.1"
}else{
versionName = "0.1.1"
}
flavor.versionName = versionName
flavor.versionCode = 50
variant.outputs.all { output ->
output.setVersionNameOverride(versionName)
output.setVersionCodeOverride(50)
}
}
reference: https://issuetracker.google.com/issues/63785806#comment6
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