Skip to content

Instantly share code, notes, and snippets.

@jimbray
Created January 6, 2017 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbray/bf52e5cc481232ea81ac3128767755ac to your computer and use it in GitHub Desktop.
Save jimbray/bf52e5cc481232ea81ac3128767755ac to your computer and use it in GitHub Desktop.
gradle 修改 release apk 名称
android {}外 定义 获取时间的函数
def release_time() {
return new Date().format("yyyy-MM-dd_HH-mm-ss")
}
更改apk 名称
//修改release apk名称
android.applicationVariants.all {
variant -> variant.outputs.each {
output -> def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
//这里修改apk文件名
def fileName = outputFile.name.replace("app","Application-${defaultConfig.versionName}-${release_time()}")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment