Skip to content

Instantly share code, notes, and snippets.

@jobwat
Forked from twocity/build.gradle
Last active December 13, 2021 07:54
Show Gist options
  • Save jobwat/2907c9a7954f4f7c602c to your computer and use it in GitHub Desktop.
Save jobwat/2907c9a7954f4f7c602c to your computer and use it in GitHub Desktop.
custom versionName with versionCode + timestamp, in release apk filename
android {
....
defaultConfig {
...
versionCode 3
versionName versionCode + "-" + getTimestamp()
}
...
...
applicationVariants.all { variant ->
println "********* " + variant.description + " **********";
def apkName = "MyAppName";
apkName += "-" + android.defaultConfig.versionName;
if (variant.buildType.name == "release") {
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent,
apkName + ".apk");
println "********* " + output.outputFile + " **********";
}
}
}
}
...
...
def getTimestamp() {
def date = new Date()
return date.format('yyyyMMdd.HHmm')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment