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));
}