在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)
}
}
}
}
生命不息百揭,奮斗不止