Last active
December 28, 2022 12:02
-
-
Save maxirosson/48c0d8160c758a9145e6 to your computer and use it in GitHub Desktop.
Versioning Android apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
ext.versionMajor = 1 | |
ext.versionMinor = 2 | |
ext.versionPatch = 3 | |
ext.versionClassifier = null | |
ext.isSnapshot = true | |
ext.minimumSdkVersion = 19 | |
android { | |
compileSdkVersion 27 | |
buildToolsVersion "27.0.0" | |
defaultConfig { | |
applicationId "com.sample" | |
targetSdkVersion 27 | |
minSdkVersion project.ext.minimumSdkVersion | |
versionCode generateVersionCode() // 190010203 | |
versionName generateVersionName() // 1.2.3-SNAPSHOT | |
} | |
} | |
private Integer generateVersionCode() { | |
return ext.minimumSdkVersion * 10000000 + ext.versionMajor * 10000 + ext.versionMinor * 100 + ext.versionPatch | |
} | |
private String generateVersionName() { | |
String versionName = "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}" | |
if (ext.versionClassifier == null && ext.isSnapshot) { | |
ext.versionClassifier = "SNAPSHOT" | |
} | |
if (ext.versionClassifier != null) { | |
versionName += "-" + ext.versionClassifier | |
} | |
return versionName; | |
} |
Hi
what will be the max limit for
private Integer generateVersionCode() {
return ext.minimumSdkVersion * 10000000 + ext.versionMajor * 10000 + ext.versionMinor * 100 + ext.versionPatch
}
this
when app version is 9999.9999.9999 is present
will this work?
Hi. This is explained here: https://medium.com/dipien/versioning-android-apps-d6ec171cfd82
The maximum supported version will be 99.99.99
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you help me on how to integrate this gradle file in CI/CD to pass incremental values automatically to these variables for every build
ext.versionMajor = 1
ext.versionMinor = 2
ext.versionPatch = 3