Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rename output apk file
android.applicationVariants.all { variant ->
// replace output apk name to <product>-<version>-<buildtype>-<githash>.apk
def versionSuffix = variant.buildType.versionNameSuffix ? variant.buildType.versionNameSuffix : ""
def versionName = variant.mergedFlavor.versionName + versionSuffix + "-${gitHash}";
if (variant.zipAlign) {
def apkFinal = variant.outputFile;
variant.outputFile = new File(apkFinal.parentFile, apkFinal.name.replace(variant.buildType.name, versionName));
}
def apkProcess = variant.packageApplication.outputFile;
variant.packageApplication.outputFile =
new File(apkProcess.parentFile, apkProcess.name.replace(variant.buildType.name, versionName));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment