Android studio插件 3.0.0以上自定义打包apk
https://blog.csdn.net/niuba123456/article/details/95907337
3. 解决方案
1. variant.outputs.each 改为 variant.outputs.all
2. output ->output.outputFile = new File(parent,fileName);改为outputFileName = fileName
3修改代码
原配置:
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent,
"dj" + "_v" +
defaultConfig.versionName + "_" + defaultConfig.versionCode + "_" +
new Date().format("yyyy-MM-dd") + "_" + buildType.name +
".apk");
}
}
修改为:
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName ="dj" + "_v" +
defaultConfig.versionName + "_" + defaultConfig.versionCode + "_" +
new Date().format("yyyy-MM-dd") + "_" + buildType.name +
".apk"
}
}