我想要你的帮助。请帮助。
错误:(63,0)无法设置只读属性的值" outputFile' for apkVariantOutputImpl_Decorated {apkData = Main {type = MAIN,fullName = debug,filters = []}},类型为com.android.build.gradle.internal.api.ApkVariantOutputImpl。打开文件
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, "kickmaterial-" + defaultConfig.versionName + ".apk")
}
}
android版本是3.0.1 请你的帮助。
答案 0 :(得分:1)
从gradle插件3.0开始,您无法像documentation中所说的那样使用each()
:
使用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" } }
因此,您需要制作如下代码的块代码:
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "$kickmaterial-${variant.versionName}.apk"
}
}