Last active
November 4, 2015 08:55
-
-
Save Qw4z1/a8312dbb571e0dd28696 to your computer and use it in GitHub Desktop.
APK file naming. Put in base directory of the project and add 'apply from: 'artifacts.gradle'' to the apps build.gradle. All credit goes to Erik Ogenvik at Jayway for his blog post http://www.jayway.com/2015/03/13/producing-better-named-android-apks-with-gradle/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android.applicationVariants.all { variant -> | |
def appName | |
//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.each {output -> | |
def newApkName | |
//If there's no ZipAlign task it means that our artifact will be unaligned and we need to mark it as such. | |
if (output.zipAlign) { | |
newApkName = "${appName}-${output.baseName}-${variant.versionCode}.apk" | |
} else { | |
newApkName = "${appName}-${output.baseName}-${variant.versionCode}-unaligned.apk" | |
} | |
output.outputFile = new File(output.outputFile.parent, newApkName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment