Reputation: 791
I'd like to use different versionCode
and versionName
for debug and release builds but I'm not sure how to achieve this. I don't want to just add suffix, I want to generate versionCode completely different between two build types. Specifically, it'd best if I can set versionCode to getDebugVersionCode()
and getReleaseVersionCode()
for debug and release builds, respectively. How can I do this? Thanks.
Upvotes: 4
Views: 2434
Reputation: 189
I think the solution you are looking for is This.
Also, here is the implementation from my gradle file:
android {
applicationVariants.all { variant ->
if (variant.buildType.isDebuggable()) {
//set properties for debug
variant.outputs.each { output ->
output.versionNameOverride = "DEBUG-VERSION";
output.versionCodeOverride = 1
}
}
}
}
Upvotes: 0
Reputation: 28126
You can try to use a solution from here.
According to it, it's possible to change versionName
and versionCode
like so:
android {
applicationVariants.all { variant ->
def flavor = variant.mergedFlavor
if (variant.buildType.isDebuggable()) {
//set properties for debug
flavor.versionName = 'version-name-for-debug`;
flavor.versionCode = 6;
} else {
//set properties for release
flavor.versionName = 'version-name-for-relese`;
flavor.versionCode = 8;
}
}
}
Upvotes: 3