Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
来源:互联网 发布:大数据解决方案公司 编辑:程序博客网 时间:2024/06/05 18:51
今天升级了AS3.0以后,在项目编译的时候发现Gradle中报错了,错误如下:
Error:(60, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=xiaomiRelease, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
<a href="openFile:E:\Studio\MyApplication\CodeBook\build.gradle">Open File</a>
经过一番折腾,网上找大牛的解读,弄明白了output.outputFile变成了只读属性,不能再往里面写东西了,以下是3.0之前的配置:
applicationVariants.all { variant -> //批量修改Apk名字variant.outputs.each { output ->def outputFile = output.outputFileif (outputFile != null && outputFile.name.endsWith('.apk') && 'release'.equals(variant.buildType.name)) {def fileName = outputFile.name.replace("${variant.flavorName}", "V${defaultConfig.versionName}-${variant.flavorName}")fileName = fileName.replace('.apk', "-${buildTime()}.apk")output.outputFile = new File(outputFile.parent, fileName)}}}
下面是经过修改之后3.0里面批量修改APK名字的配置:
applicationVariants.all { variant -> //批量修改Apk名字variant.outputs.all { output ->if (!variant.buildType.isDebuggable()) {//获取签名的名字 variant.signingConfig.name//要被替换的源字符串def sourceFile = "-${variant.flavorName}-${variant.buildType.name}"//替换的字符串def replaceFile = "_V${variant.versionName}_${variant.flavorName}_${variant.buildType.name}_${buildTime()}"outputFileName = output.outputFile.name.replace(sourceFile, replaceFile);//遗留问题:如何获取当前module的name,如CodeBooke这个名字怎么获取到}}}
问题:对于如何在gradle中获取module的name,还是没有找到相关的方法,希望有知道的大神留言交流。
gradle API:https://developer.android.google.cn/studio/build/gradle-plugin-3-0-0-migration.html#variant_api
这是一个对AS 3.0变化总结比较全的博客:
https://mp.weixin.qq.com/s?__biz=MzAwNzc0NjAxMg==&mid=2653391711&idx=1&sn=821eff3f98ab52fc442c6218794b203e&chksm=80aa53ecb7dddafa522d4ebfdf67af2f473365bb0fa2d50ae6df5d00499926ae0d32a5a448d2&mpshare=1&scene=23&srcid=10308c4ICo7GCwuVc683H6eZ#rd
阅读全文
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
- php 二维数组根据某字段去重
- 形状约束——asm
- 备案图标网站位置调整
- 时间复杂度与空间复杂度
- date1208关于ATM项目评审
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- 欢迎使用CSDN-markdown编辑器
- vue基本使用--refs获取组件或元素
- 实现二分查找算法的递归及非递归
- C++ STL之vector用法总结
- 【Scikit-Learn 中文文档】最近邻
- Nginx的配置-基础配置项
- 缺少jstl-1.2jar 引起的jsp页面错误
- Linux权限管理