无法为ApkVariantOutputImpl_Decorated设置只读属性'outputFile'的值 [英] Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated

查看:114
本文介绍了无法为ApkVariantOutputImpl_Decorated设置只读属性'outputFile'的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gradle脚本中使用以下代码来重命名由AndroidStudio生成的apk:

I was using the following code in my gradle script to rename the apks generated with AndroidStudio:

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.outputFile = new File(output.outputFile.parent, defaultConfig.versionCode + "_" + output.outputFile.name)
    }
}

因此它正在生成名称如下的APK: 345-app-release.apk ,其中345是versionCode.

So it was generating apks with names like: 345-app-release.apk, where 345 is the versionCode.

但是更新到AndroidStudio 3.0后,它会返回以下错误:

But after updating to AndroidStudio 3.0 it returns the following error:

无法为以下项设置只读属性'outputFile'的值 ApkVariantOutputImpl_Decorated {apkData = Main {type = MAIN,fullName = debug, 过滤器= []}}的类型 com.android.build.gradle.internal.api.ApkVariantOutputImpl.

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.

如何使用新的构建工具实现类似的重命名.

How can I achieve a similar renaming with the new build tools.

推荐答案

使用output.outputFileName代替output.outputFile

这篇关于无法为ApkVariantOutputImpl_Decorated设置只读属性'outputFile'的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆