Android Studio更新后,出现以下图片错误,
这里是项目build.gradle代码,
debug {
minifyEnabled false
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent,
output.outputFile.name.replace("app-debug.apk", "GoodWeather-debug-${variant.versionName}.apk"))
答案 0 :(得分:0)
在构建时修改变体输出可能不起作用
使用Variant 使用新插件打破了操纵变量输出的API。它 仍适用于简单的任务,例如更改APK名称 构建时间,如下所示:
// If you use each() to iterate through the variant objects, // you need to start using all(). That's because each() iterates // through only the objects that already exist during configuration time— // but those object don't exist at configuration time with the new model. // However, all() adapts to the new model by picking up object as they are // added during execution. android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "${variant.name}-${variant.versionName}.apk" } }
来源:https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html