I am trying to use android build tools "com.android.tools.build:gradle:3.0.0-alpha4" in my project. In my build script I rename the output apk which worked fine in the past but does not seem to be supported any more.
applicationVariants.all { variant ->
def filename = "foo-${variant.baseName}-${variant.versionName}-(${android.defaultConfig.versionCode}).apk"
variant.outputs.all { output ->
output.outputFile = new File(
output.outputFile.parent,
filename
)
}
}
Now the propery I am trying to change became immutable:
Error: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=stageDebug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
Is there a new or an alternate way how to do this?
each
-> to all
output.outputFile
-> to outputFileName
before:
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def finalVersionCode =v10000 + versionCode
output.versionCodeOverride = finalVersionCode
output.outputFile = new File(
output.outputFile.parent, output.outputFile.name.replace(".apk","-${finalVersion}.apk"))
}
}
after:
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def finalVersionCode = 10000 + versionCode
output.versionCodeOverride = finalVersionCode
outputFileName = new File(
output.outputFile.parent,
outputFileName.replace(".apk", "-${finalVersionCode}.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