1

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-ecb77811b938

When I imported the project to Android Studio, I got the following error - Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated I 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.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
TomJ
  • 1,803
  • 14
  • 37
  • 57

1 Answers1

3

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.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216