use a better apk name

found here
https://github.com/jayway/AndroidGradleExample/blob/master/artifacts.gradle
This commit is contained in:
Frank Morgner
2016-04-05 00:08:20 +02:00
parent 1d3e5fe4fd
commit caff142b0b

View File

@@ -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 { repositories {
mavenCentral() mavenCentral()
} }