我想在我的项目中使用android构建工具“com.android.tools.build:gradle:3.0.0-alpha4”。在我的构建脚本中,我重命名了以前可以正常工作的输出apk,但似乎不再受到支持。在gradle中更改apk文件的名称
applicationVariants.all { variant ->
def filename = "foo-${variant.baseName}-${variant.versionName}-(${android.defaultConfig.versionCode}).apk"
variant.outputs.all { output ->
output.outputFile = new File(
output.outputFile.parent,
filename
)
}
}
现在我试图改变属性格式成为不可改变的:
Error: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=stageDebug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
是否有新的或替代方法如何做到这一点?
可能重复[等级插件3-alpha1 outputFile导致错误](https://stackoverflow.com/questions/44044031/grade-plugin-3-alpha1-outputfile-causes-error) –
我得到的错误其实是不同的和提供的解决方案不适合我。似乎是alpha-4中的一个新问题。编辑我的示例以反映官方文档的解决方案无效。 – Hendrik
可能的重复https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property –