Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
2018-03-04 20:01
671 查看
详细报错:
位置:
Android plugin 3.0 建议使用
Error:(45, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=xiaomiDebug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl. <a href="openFile:H:\CloudMus\app\build.gradle">Open File</a>
位置:
// 自定义输出配置 // applicationVariants.all { variant -> // variant.outputs.each { output -> // def outputFile = output.outputFile // if (outputFile != null && outputFile.name.endsWith('.apk')) { // // 输出apk名称为great_v1.0_wandoujia.apk // def fileName = "great${defaultConfig.versionName}_${variant.productFlavors[0].name}.apk" // output.outputFile = new File(outputFile.parent, fileName) // } // } // }
Android plugin 3.0 建议使用
Use all() instead of each() Use outputFileName instead of output.outputFile if you change only file name (that is your case)例子:
// If you use each() to iterate through the variant objects, // you need to start using all(). That's because each() iterates // through only the objects that already exist during configuration time— // but those object don't exist at configuration time with the new model. // However, all() adapts to the new model by picking up object as they are // added during execution. android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "${variant.name}-${variant.versionName}.apk" } }故而修改上面的写法:
applicationVariants.all { variant -> variant.outputs.all { // 输出apk名称为great_v1.0_wandoujia.apk def fileName = "great${defaultConfig.versionName}_${variant.productFlavors[0].name}.apk" outputFileName = fileName } }
相关文章推荐
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
- 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
- Error:Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apk
- 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 ApkVariantOutputImpl
- android studio3.0 编译 Cannot set the value of read-only property 'outputFile' for apkVariantOutputImp
- Error:(45, 0) Cannot set the value of read-only property 'outputFile' for ...
- “Cannot set the value of read-only property 'outputFile' for 。。。”解决
- Cannot set the value of read-only property 'outputFile'
- android studio3.0(二)Cannot set the value of read-only property 'outputFile'
- Cannot set the value of read-only property 'outputFile'
- Android Gradle 3.0.0-alpha2 plugin, Cannot set the value of read-only property 'outputFile'
- Can not set the value of read-only property 'jniFolders' for task ': android: packageDebug