Ensure versionCode is the wanted one for GPlay and F-Droid build

This commit is contained in:
Benoit Marty 2019-08-07 16:51:39 +02:00 committed by Benoit Marty
parent 5a9d88e791
commit 93fd56a7ca

View File

@ -71,9 +71,7 @@ android {
targetSdkVersion 28 targetSdkVersion 28
multiDexEnabled true multiDexEnabled true


// For release, use generateVersionCodeFromVersionName() // Note: versionCode is depending on the build variant
versionCode generateVersionCodeFromTimestamp()
//versionCode generateVersionCodeFromVersionName()


versionName "${versionMajor}.${versionMinor}.${versionPatch}-dev" versionName "${versionMajor}.${versionMinor}.${versionPatch}-dev"


@ -117,9 +115,10 @@ android {
} }
} }


android.applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def baseAbiVersionCode = project.ext.abiVersionCodes.get(output.getFilter(OutputFile.ABI)) def baseAbiVersionCode = project.ext.abiVersionCodes.get(output.getFilter(OutputFile.ABI))
// Known limitation: it does not modify the value in the BuildConfig.java generated file
output.versionCodeOverride = baseAbiVersionCode * 10_000_000 + variant.versionCode output.versionCodeOverride = baseAbiVersionCode * 10_000_000 + variant.versionCode
} }
} }
@ -162,6 +161,8 @@ android {
gplay { gplay {
dimension "store" dimension "store"


versionCode = generateVersionCodeFromVersionName()

buildConfigField "boolean", "ALLOW_FCM_USE", "true" buildConfigField "boolean", "ALLOW_FCM_USE", "true"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\"" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\""
@ -170,6 +171,8 @@ android {
fdroid { fdroid {
dimension "store" dimension "store"


versionCode = generateVersionCodeFromTimestamp()

buildConfigField "boolean", "ALLOW_FCM_USE", "false" buildConfigField "boolean", "ALLOW_FCM_USE", "false"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\"" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""