Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated

Use output.outputFileName instead of output.outputFile


2019 - Simple Solution for Gradle 3.0+** and 3.1.0

To change the name of the APK in Android

 android { //add inside the android {}
   ......
   applicationVariants.all { variant ->
       variant.outputs.all {
           def flavor = variant.name
           def versionName = variant.versionName
           outputFileName = "prefix_${flavor}_${versionName}.apk"
       }
   }
}

prefix_release_1.0.1.apk


Try this code :

buildTypes {

       applicationVariants.all { variant ->
            variant.outputs.each { output ->
                def name = "myapp_v${variant.versionName}(${variant.versionCode}).apk"
                output.outputFileName = name
            }
        }

    }