在build.gradle中添加如下代码
release {
//自定义包名输出格式
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// 输出apk名称为MyApp-V1.0.0-20180201.apk
def fileName = "MyApp"+ "-V" + defaultConfig.versionName + "-"
+ new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC")) +".apk";
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
生命不息,奋斗不止