Created
October 24, 2014 00:37
-
-
Save sddamico/75747761a4f738afc308 to your computer and use it in GitHub Desktop.
Rename Android APK's to Something Useful
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
/* put this in your application's build.gradle after the android {} block | |
* output is in this format: "<projectName>-<buildType>-v<versionName>-<versionCode>.apk" | |
* e.g. "materiyolo-debug-v5.0.0-12345.apk" | |
* also, supports injecting jenkins ci's build number into apk, if available | |
* e.g. "materiyolo-debug-v5.0.0-12345-b6789.apk" | |
* you must specify your versionName and versionCode in your build.gradle for this to work | |
* see: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Manifest-entries */ | |
// change this to whatever your app's name is... | |
project.archivesBaseName = 'materiyolo' | |
android.applicationVariants.all { variant -> | |
renameApk(variant) | |
} | |
def renameApk(variant) { | |
def apkPath = variant.packageApplication.outputFile.parentFile | |
def baseName = project.archivesBaseName | |
// if it's a release build, the type is implicit, imo, so add it otherwise | |
if (variant.name != 'release') { | |
baseName += "-${variant.buildType.name}" | |
} | |
// add version name and version code | |
baseName += "-v${variant.mergedFlavor.versionName}-${variant.mergedFlavor.versionCode}" | |
// if built on jenkins ci, add jenkins build number: | |
def buildNumber = System.getenv('BUILD_NUMBER') | |
if (buildNumber && buildNumber.size() > 0) { | |
baseName += "-b${buildNumber}" | |
} | |
// if the variant will not be zipAligned, specify that | |
if (!variant.zipAlign) { | |
baseName += '-unaligned' | |
} | |
// set the output file | |
variant.outputFile = new File(apkPath, "${baseName}.apk"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same for me:
A problem occurred configuring project ':client'.