转载请标明出处: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. Spring Web工程web.xml零配置即使用Java Config + Annotation

    摘要: 在Spring 3.0之前,我们工程中常用Bean都是通过XML形式的文件注解的,少了还可以,但是数量多,关系复杂到后期就很难维护了,所以在3.x之后Spring官方推荐使用Java Conf ...

  2. 配置phpstorm自动上传代码

    本地的项目目录是 D:\www\guandan 虚拟机上的项目目录是 /var/www/guandan

  3. ES7 Async/Await 陷阱

    什么是Async/Await ES6新增了Promise函数用于简化项目代码流程.然而在使用promise时,我们仍然要使用callback,并且并不知道程序要干什么,例如: function doS ...

  4. app后端设计(6)-- LBS

    在LBS的应用中,一个基本的需求是查找附近的用户,现在有两种做法: 1. 使用mysql的空间数据库,具体做法参考:http://blog.sina.com.cn/s/blog_a48af8c0010 ...

  5. 巩固java(三)---java修饰符

    正文:               下面的表格列出了java中修饰符的一些信息: 修饰符名称 类型 类 变量 方法 abstract 非访问控制符 抽象类          -- 抽象方法 final ...

  6. 优化TestNG测试报告

    以下内容引自: https://www.cnblogs.com/jwentest/p/7073223.html 优化testng报告   背景 搞过testng的同学都知道,testng自带的报告非常 ...

  7. c# 如何找到项目中图片的相对路径

    c# 如何找到项目中图片的相对路径 string path = System.Environment.CurrentDirectory;//非Web程序if (System.Environment.C ...

  8. 排序1,2......n的无序数组,时间复杂度为o(n),空间复杂度为o(1)

    #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _T ...

  9. laravel 5.4中手动创建分页

    这里是参考的的链接https://blog.csdn.net/hxx_yang/article/details/51753134 use Illuminate\Pagination\LengthAwa ...

  10. 磁盘IOPS计算与测量

    IOPS (Input/Output Per Second)即每秒的输入输出量(或读写次数),是衡量磁盘性能的主要指标之一.IOPS是指单位时间内系统能处理的I/O请求数量,一般以每秒处理的I/O请求 ...