'Android (Studio) | How is version name defined in Android?
build.gradle
def readVersion() {
Properties version = new Properties()
File propFile = file("version.properties")
FileInputStream stream
try {
if (propFile.canRead()) {
stream = new FileInputStream(propFile)
version.load(stream)
}
} catch (Exception ex) {
FirebaseCrashlytics.getInstance().recordException(ex)
println ex
}
finally {
if (stream != null) stream.close()
}
if (!version['major']) version['major'] = "1"
if (!version['minor']) version['minor'] = "0"
return version
}
def readVersionName() {
def version = readVersion()
return "${version['major']}.${version['minor']}"
}
static def readVersionCode() {
def cmd = "git rev-list --count HEAD"
return cmd.execute().text as int
}
I can determine the version code and version name in the app via
String versionCode = String.valueOf(BuildConfig.VERSION_CODE);
String versionName = String.valueOf(BuildConfig.VERSION_NAME);
Version code is determined by querying "git rev-list --count HEAD", that makes sense to me.
So far so good. But how is version name determined? With my app I get the version name 1.1 But how does that happen? When will it be 2.1 or 1.2 etc. Can I influence that?
Does it have to do with this piece of code of gradle. Why then there is 1 and 0, but in the end 1.1 comes out, I don't get it at all. An what about version.properties, where is that located and what is it for?
if (!version['major']) version['major'] = "1"
if (!version['minor']) version['minor'] = "0"
I've made so many changes to my project, only the version code changes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
