Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
来源:互联网 发布:对对子软件 编辑:程序博客网 时间:2024/05/21 09:23
之前在旧版本Android Studio中用以下代码修改过release版本的apk名:
applicationVariants.all { variant -> variant.outputs.each { output -> def SEP = "_" def flavor = variant.productFlavors[0].name def buildType = variant.variantData.variantConfiguration.buildType.name def version = variant.versionName def date = new Date() def formattedDate = date.format('ddMMyy_HHmm') def newApkName = PROJECT_NAME + SEP + flavor + SEP + buildType + SEP + version + SEP + formattedDate + ".apk" def file = new File(newApkName) output.outputFile = file }}
然而升级Android Studio 3.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.
原因
Android Studio 3.0 修改了打包规则,详细规则见 Android plugin 3.0 migration guide(需翻墙)
解决方法
使用 all() 替换 each()
使用 outputFileName 替换 output.outputFile
示例
// 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" }}
参考链接:
https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
阅读全文
0 0
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- [Exception]Cannot set the value of read-only property 'outputFile'
- Cannot set the value of read-only property 'outputFile'
- Cannot set the value of read-only property 'outputFile'
- android studio3.0 编译 Cannot set the value of read-only property 'outputFile' for apkVariantOutputImp
- annot set the value of read-only property 'outputFile'
- android studio3.0(二)Cannot set the value of read-only property 'outputFile'
- Can not set the value of read-only property 'jniFolders' for task ': android: packageDebug
- set the property read only
- Cannot read property 'value' of null
- Cannot set property 'value' of null
- Cannot set property 'value' of undefined
- Uncaught TypeError: Cannot read property 'value' of null
- Mysql-注意事项
- 对于NB-IoT、eMTC和LoRa市场的8点判断
- iOS朋友圈,视频播放器、钓鱼小游戏、玻璃动画源码
- Battle HDU
- ViewPager轮播切换带动画效果
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- 自己申请软件著作权
- Android之我当年爬过的坑
- 数据库事务的四大特性以及事务的隔离级别整理
- 开博札记
- java获取方法的参数名称
- redis知识盘点【贰】_五种类型
- 蓝牙低功耗BLE在智产品的应用
- 9、Python xlsxwriter模块