Created
January 6, 2017 07:37
-
-
Save jimbray/bf52e5cc481232ea81ac3128767755ac to your computer and use it in GitHub Desktop.
gradle 修改 release apk 名称
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 {}外 定义 获取时间的函数 | |
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