Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{...
转载请标明出处:https://www.cnblogs.com/tangZH/p/10764568.html
更多精彩文章:http://77blogs.com/?p=298
在做多渠道打包的时候出现了这个错误,在高版本的gradle出现。
具体错误为: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.
我的代码为下:

这个在低版本的gradle是行得通的,但是高版本就不行。
高版本的应该这样:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "novel_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"
outputFileName = fileName
}
}
}
}
}
将variant.outputs.each改为variant.outputs.all
将output.outputFile = new File(outputFile.parent, fileName)改为outputFileName = fileName
Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{...的更多相关文章
- Could not find property 'outputFile
* What went wrong: A problem occurred configuring project ':app'. > Could not find property 'outp ...
- Gradle sync failed: Cannot set the value of read-only property 'outputFile'
错误 Gradle sync failed: Cannot set the value of read-only property 'outputFile' 原因 gradle打包,自定义apk名称代 ...
- Android Studio 中修改Apk名称
修改生成的apk名称,并且使调试时也可以使用. 在app->build.gradle 中增加以下内容: android.applicationVariants.all { variant-> ...
- 升级到 Android Studio 3.0 + Gradle 4.1 遇到的一些坑及解决方案
问题一: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkD ...
- Android Studio 3.0正式版填坑之路
原文:https://www.jianshu.com/p/9b25087a5d7d Android Studio 3.0启动图 序言 总看别人的文章,今天尝试着自己来写一篇.在逛论坛时候,无意间发 ...
- 浅谈Android Studio3.0更新之路(遇坑必入)
>可以参考官网设置-> 1 2 >> Fantasy_Lin_网友评论原文地址是:简书24K纯帅豆写的我也更新一下出处[删除]Fa 转自脚本之家 浅谈Android Studi ...
- Android gradle 相关配置
有时候我们需要重命名输出apk文件名,在Android studio 3.0以前我们是这样写的: applicationVariants.all { variant -> variant.out ...
- Android常见错误整理
1.当我new class的时候,提示以下错误: Unable to parse template "Class" Error message: This template did ...
- 升级到Android Studio3.x遇到的问题及解决方案
升级到Android Studio3.x遇到的问题及解决方案 转 https://www.2cto.com/kf/201711/695736.html 升级到Android Studio3.0遇到的问 ...
随机推荐
- Thymeleaf中each标签遍历list如何获取index
<tr th:each="user,userStat:${users}">userStat是状态变量,有 index,count,size,current,even,o ...
- springMVC(spring)+WebSocket案例(获取请求参数)
开发环境(最低版本):spring 4.0+java7+tomcat7.0.47+sockjs 前端页面要引入: <script src="http://cdn.jsdelivr.ne ...
- mybatis的使用
1.like 的使用范例 name like CONCAT(CONCAT('%', #{name}), '%') 2.时间的比较的范例 <![CDATA[ and bill_date >= ...
- 如何在js或者jquery中操作EL表达式的一个List集合
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 先说明此篇博客看明白了可以干嘛: 就是在js或者jquery中操作一个EL表达式的一个list集合或者复杂类型 ...
- Extjs 上传文件 IE不兼容的问题[提示下载保存]
我最不喜欢的浏览器的是IE,但无奈很多项目的客户使用的是IE. 在使用Extjs做文件上传时,其他浏览器没有问题,但IE却一个劲提示保存文件,看服务端运行,它其实是运行成功了已经,但客户端的进度条却一 ...
- 玩转SSH--Hibernate(三)---手动修改数据库,前台查询信息不同步更新问题解决方法
在用hibernate时遇到一个挺纠结的问题,就是我在手动修改数据库的信息后,前台页面查询到的信息还是之前的结果,一开始以为是缓存的问题,经过多次修改和在网上查询资料,最终发现可能是hibernate ...
- celery学习笔记1
生产者消费者模式 在实际的软件开发过程中,经常会碰到如下场景:某个模块负责产生数据,这些数据由另一个模块来负责处理(此处的模块是广义的,可以是类.函数.线程.进程等).产生数据的模块,就形象地称为生产 ...
- python反编译工具
开发类在线工具:https://tool.lu/一个反编译网站:https://tool.lu/pyc/ 一看这个标题,就是搞坏事用的, 用 java 写程序多了,很习惯用反编译工具了,而且玩java ...
- JFree图表
************************************************************************************* 使用JFree生成统计图片, ...
- JLOI2018 划水中...
day -3:月考成绩刚刚出炉,嗯,还看得过去,为此,我决定脱产3天...花了一天时间,学习splay day -2:在某人(汤)的刺激下,决定用半天时间A掉去年省选D2T1,事实证明,我还是图样图森 ...