转载
https://blog.csdn.net/LVXIANGAN/article/details/84030555
解决了报错 Cannot set the value of read-only property ‘outputFile‘ for
在app.gradle的android节点中添加
android {
//...
//...
//...
// 自定义包名
applicationVariants.all { variant ->
variant.outputs.all { output ->
// test_版本号_yyyymmdd_release.apk
def fileName = "xxx_${variant.versionName}_${releaseTime()}.apk"
def outFile = output.outputFile
if (outFile != null && outFile.name.endsWith('.apk')) {
outputFileName = fileName
}
}
}
}
def releaseTime() {
return new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC"))
}
编译后生成自定义名称的apk,如下图