Skip to content

Instantly share code, notes, and snippets.

@shakalaca
Created September 2, 2013 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shakalaca/6414702 to your computer and use it in GitHub Desktop.
Save shakalaca/6414702 to your computer and use it in GitHub Desktop.
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