I\'m using Gradle to compile my Android project:
buildTypes {
release {
signingConfig signingConfigs.release
applicationVariants.all { varia
There should be 3 output APK files when using your build.gradle configuration: debug unsigned unaligned, release signed aligned and release signed unaligned. There are two variables for applicationVariant
to deal with output files: outputFile and packageApplication.outputFile, the former is used for zipalign and the later is used in general case.
So the proper way to rename all the files will be like this:
android.applicationVariants.all { variant ->
if (variant.zipAlign) {
def oldFile = variant.outputFile;
def newFile = oldFile.name.replace(".apk", "-renamed.apk")
variant.outputFile = new File(oldFile.parent, newFile)
}
def oldFile = variant.packageApplication.outputFile;
def newFile = oldFile.name.replace(".apk", "-renamed.apk")
variant.packageApplication.outputFile = new File(oldFile.parent, newFile)
}