转载请标明出处: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{...的更多相关文章

  1. Could not find property 'outputFile

    * What went wrong: A problem occurred configuring project ':app'. > Could not find property 'outp ...

  2. 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名称代 ...

  3. Android Studio 中修改Apk名称

    修改生成的apk名称,并且使调试时也可以使用. 在app->build.gradle 中增加以下内容: android.applicationVariants.all { variant-> ...

  4. 升级到 Android Studio 3.0 + Gradle 4.1 遇到的一些坑及解决方案

    问题一: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkD ...

  5. Android Studio 3.0正式版填坑之路

    原文:https://www.jianshu.com/p/9b25087a5d7d   Android Studio 3.0启动图 序言 总看别人的文章,今天尝试着自己来写一篇.在逛论坛时候,无意间发 ...

  6. 浅谈Android Studio3.0更新之路(遇坑必入)

    >可以参考官网设置-> 1 2 >> Fantasy_Lin_网友评论原文地址是:简书24K纯帅豆写的我也更新一下出处[删除]Fa 转自脚本之家 浅谈Android Studi ...

  7. Android gradle 相关配置

    有时候我们需要重命名输出apk文件名,在Android studio 3.0以前我们是这样写的: applicationVariants.all { variant -> variant.out ...

  8. Android常见错误整理

    1.当我new class的时候,提示以下错误: Unable to parse template "Class" Error message: This template did ...

  9. 升级到Android Studio3.x遇到的问题及解决方案

    升级到Android Studio3.x遇到的问题及解决方案 转 https://www.2cto.com/kf/201711/695736.html 升级到Android Studio3.0遇到的问 ...

随机推荐

  1. TensorFlow-谷歌深度学习库 文件I/O Wrapper

    这篇文章主要介绍一下TensorFlow中相关的文件I/O操作,我们主要使tf.gfile来完成. Exists tf.gfile.Exists(filename) 用来判断一个路径是否存在,如果存在 ...

  2. CXF整合spring

    近公司需要弄webservics,还说不用框架整合(提倡使用hessian,他们既然说与操作系统有兼容问题,由于人员单薄,不得不屈服,哎),我想了老半天没弄明白他说的不用框架整合spring,尝试过直 ...

  3. Collection、List、Set集合概括

    1.Collection是一个接口,定义了集合相关的操作方法,其有两个子接口List和Set. 2.List和Set的区别    List是有序的可重复集合,Set是无序的不可重复集合. 3.集合持有 ...

  4. 二十六、Hadoop学习笔记————Hadoop Yarn的简介复习

    1. 介绍 YARN(Yet Another Resource Negotiator)是一个通用的资源管理平台,可为各类计算框架提供资源的管理和调度. 之前有提到过,Yarn主要是为了减轻Hadoop ...

  5. SSM-Spring-02:Spring的DI初步加俩个实例

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- DI:依赖注入 第一个DEMO:域属性注入 java类:(Car类和Stu类,学生有一辆小汽车) packag ...

  6. Intent的跳转和传值

    看了Intent的使用方法,感觉还是要做一些笔记的,首先对于Intent的跳转Activity这个功能的实现就有两种方法,也可以说有三种: 1.                  2.

  7. Web开发:需收藏的JavaScript常用技巧

    原文来自:https://www.baidu.com/home/news/data/newspage?nid=4242707244478773456&n_type=0&p_from=1 ...

  8. mysqldump详解

    Ⅰ.mysqldump的简单使用与注意点 1.1 基本参数 只备份innodb,用不了几个参数,记住下面几个即可,其他的没什么卵用 -A 备份所有的database -B 备份哪几个数据库 -R 备份 ...

  9. 关于数据库报Packet for query is too large (1986748 > 1048576)(mysql写入数据过大)的解决办法

    方法2 (很妥协,很纠结的办法) 进入mysql server 在mysql 命令行中运行 set global max_allowed_packet = 2*1024*1024*10 然后关闭掉这此 ...

  10. 利用post请求发送内容进行爬虫

    利用post请求发送内容进行爬虫 import requests url = 'http://www.iqianyue.com/mypost' header = {} header['Accept-L ...