From caff142b0b10e466b9a5de84680b915b9619a63a Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Tue, 5 Apr 2016 00:08:20 +0200 Subject: [PATCH] use a better apk name found here https://github.com/jayway/AndroidGradleExample/blob/master/artifacts.gradle --- remote-reader/app/build.gradle | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/remote-reader/app/build.gradle b/remote-reader/app/build.gradle index 8e77211..970d790 100644 --- a/remote-reader/app/build.gradle +++ b/remote-reader/app/build.gradle @@ -21,6 +21,27 @@ android { } } +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) + } +} + repositories { mavenCentral() }