Cannot set the value of read-only property 'outputFile'
来源:互联网 发布:插座开关推荐 知乎 编辑:程序博客网 时间:2024/05/19 11:19
更新Android Studio 3.0之后,出现Cannot set the value of read-only property ‘outputFile’报错,也就是用来打包后重命名的gradle出现了问题
旧版本
AS 2.3时用的代码:
applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { def fileName = "driver_${variant.productFlavors[0].name}_v${defaultConfig.versionName}.apk" output.outputFile = new File(outputFile.parent, fileName) } } }
修改之后:
flavorDimensions 'api' productFlavors { ... } android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "driver_${variant.productFlavors[0].name}_v${variant.versionName}.apk" } }
关于flavorDimensions可查看官方文档
https://developer.android.google.cn/studio/build/build-variants.htm
参考资料
答案来源:https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
官方文档解析:https://developer.android.google.cn/studio/build/gradle-plugin-3-0-0-migration.html#variant_api
阅读全文
0 0
- [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'
- annot set the value of read-only property 'outputFile'
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- android studio3.0(二)Cannot set the value of read-only property 'outputFile'
- 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
- android studio3.0 编译 Cannot set the value of read-only property 'outputFile' for apkVariantOutputImp
- 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
- 为什么$this能访问static的function呢?
- Codeforces Round #441 (Div. 1) C:National Property(2-SAT)
- 解决:Some index files failed to download. They have been ignored, or old ones used instead.
- 【头条】思杰的新定位:做企业云转型伙伴和使能者
- Codevs1227 方格取数2
- Cannot set the value of read-only property 'outputFile'
- [BZOJ1711]Dining 吃饭 最大流
- 2台服务器之间拷贝文件
- hdu-1002 A + B Problem II_(高精度加法)
- Linux_day1
- Command /usr/bin/codesign failed with exit code 1
- ubuntu安装idea
- 购物车——(查询,排序)
- 回文数猜想