gpt4 book ai didi

java - 错误 :(63, 0) 无法设置只读属性 'outputFile' 的值

转载 作者:行者123 更新时间:2023-12-02 11:34:04 26 4
gpt4 key购买 nike

我需要你的帮助。请我帮忙。

Error:(63, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl. Open File

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开始,你不能像documentation那样使用each()说:

Using the Variant API to manipulate variant outputs is broken with the new plugin. It still works for simple tasks, such as changing the APK name during build time, as shown below:

// 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"
}
}
<小时/>

因此,您需要使 block 代码如下所示:

android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "$kickmaterial-${variant.versionName}.apk"
}
}

关于java - 错误 :(63, 0) 无法设置只读属性 'outputFile' 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49080719/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com