我想在我的項目中使用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 –