详细错误:
Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[], versionCode=3, versionName=3.1.112}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
Open File
代码:
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
//这里修改apk文件名
def fileName = "新移动客户端.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
修改:

解决Gradle中设置输出文件名的问题
本文解决了一个在使用Gradle构建Android项目时遇到的错误:无法为只读属性'outputFile'设置值。通过调整代码逻辑,成功地在构建过程中修改了APK的输出文件名。
8456

被折叠的 条评论
为什么被折叠?



