所以请帮助我解决错误.解决方案在更高版本的Gradle中,其工作原理与此类似:android.applicationVariants.all { variant -> variant.outputs.all { output -> def fileName = "${project.name}_${output.baseName}-${variant.versionName}.apk" outputFileName = new File(output.outputFile.parent, fileName).getName() }}因为output.outputFileName是(或已成为)只读属性.I am a newbie to Android. So as part of my learning I was following this tutorial to make an icon pack - https://blog.prototypr.io/how-to-create-an-android-icon-pack-app-ecb77811b938When I imported the project to Android Studio, I got the following error - Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_DecoratedI solved that error as the answer was already mentioned there. After that when I tried to build the project I got the following error - Absolute path are not supported when setting an output file name.When I opened the file in Android Studio, it showed that the error was occuring in the following code:applicationVariants.all { variant -> variant.outputs.each { output -> output.outputFileName = new File( output.outputFile.parent, "MyIconPack-${variant.versionName}.apk") }}So I searched here again and found this - android studio 3.1: build:gradle:3.1.0 - Absolute path are not supported when setting an output file name, but I was unable to understand the answer for that question.So please help me to solve the error. 解决方案 it works alike this with later version of Gradle:android.applicationVariants.all { variant -> variant.outputs.all { output -> def fileName = "${project.name}_${output.baseName}-${variant.versionName}.apk" outputFileName = new File(output.outputFile.parent, fileName).getName() }}because output.outputFileName is (or had become) a read-only property. 这篇关于Gradle版本4.6-设置输出文件名时不支持绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 01:44