Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Name APK output file in following format - {AppName}-{ProductFlavorName}-{BuildTypeName}-{shortGitSha}.apk (Works with Android Gradle Plugin 3.x)
//1. Put this file in the root of your project
//2. Add apply from: "../artifacts.gradle" to the end of your app module's build.gradle file
android.applicationVariants.all { variant ->
def appName
def shortGitSha = 'git rev-parse --short HEAD'.execute().text.trim()
//Check if an applicationName property is supplied; if not use the name of the parent project.
if (project.hasProperty("applicationName")) {
appName = applicationName
} else {
appName =
variant.outputs.all {
outputFileName = "${appName}-${variant.mergedFlavor.versionName}-${variant.productFlavors[0].name}-${}-${shortGitSha}.apk"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment