我需要你的帮助。 请我帮忙。
错误:(63, 0(无法为 com.android.build.gradle.internal.api.ApkVariantOutputImpl 类型的 ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} 设置只读属性 'outputFile' 的值。打开文件
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, "kickmaterial-" + defaultConfig.versionName + ".apk")
}
}
安卓版本是 3.0.1请你帮忙。
从 gradle 插件 3.0 开始,你不能像文档中所说的那样使用each()
:
使用变体 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"
}
}