我想要你的帮助。拜托,求助。
错误:(63,0)无法为com.android.build.gradle类型的ApkVariantOutputImpl_Decorated {apkData = Main {type = MAIN,fullName = debug,filters = []}}设置只读属性'outputFile'的值。 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请大家帮忙。
从gradle插件3.0开始,你不能像each()
那样使用documentation说:
使用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"
}
}