Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dptsolutions/31e06d0990b7e18cea48b8277f152d7a to your computer and use it in GitHub Desktop.
Save dptsolutions/31e06d0990b7e18cea48b8277f152d7a to your computer and use it in GitHub Desktop.
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 = parent.name
}
variant.outputs.all {
outputFileName = "${appName}-${variant.mergedFlavor.versionName}-${variant.productFlavors[0].name}-${variant.buildType.name}-${shortGitSha}.apk"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment