Created
July 13, 2016 20:00
-
-
Save tunjos/e2302ec8dc5843195daa24491f1cba5e to your computer and use it in GitHub Desktop.
Producing better named Android APKs with Gradle
This file contains 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
apply from: "../artifacts.gradle" |
This file contains 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.versionName}.apk" | |
} else { | |
newApkName = "${appName}-${output.baseName}-${variant.versionName}-unaligned.apk" | |
} | |
output.outputFile = new File(output.outputFile.parent, newApkName) | |
} | |
} |
This file contains 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
#Use line below to use "FooBar" as application name when generating APK files. | |
applicationName=FooBar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment