I am using the following simplified configuration in an Android application project.
android {
compileSdkVersi
The complete code snippet looks like that one:
// Customize generated apk's name with version number
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def manifestParser = new com.android.builder.core.DefaultManifestParser()
def fileName = outputFile.name.replace(".apk", "-DEBUG-" + manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile) + ".apk")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}