I was using the following code in my gradle script to rename the apks generated with AndroidStudio:
applicationVariants.all { variant -> variant.outputs.each { output -> output.outputFile = new File(output.outputFile.parent, defaultConfig.versionCode + "_" + output.outputFile.name) } }
So it was generating apks with names like: 345-app-release.apk, where 345 is the versionCode.
But after updating to AndroidStudio 3.0 it returns the following error:
Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
How can I achieve a similar renaming with the new build tools.
Use output.outputFileName
instead of output.outputFile
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With