Skip to content

Instantly share code, notes, and snippets.

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,, versionName));
def apkProcess = variant.packageApplication.outputFile;
variant.packageApplication.outputFile =
new File(apkProcess.parentFile,, versionName));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment