-
-
Save jobwat/2907c9a7954f4f7c602c to your computer and use it in GitHub Desktop.
custom versionName with versionCode + timestamp, in release apk filename
This file contains 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
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