Cordova uses gradle to do its Android builds. The gradle build configuration is in platforms/android/build.gradle but you shouldn't edit this file. Extensions can be added by adding a file named build-extras.gradle
to platforms/android/
as documented here. My project uses gulp so I used that to copy it from my project's source directory.
build-extras.gradle
should contain (source):
def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--dirty'
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (ignored) {
return null;
}
}
android {
buildTypes {
debug {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent,
file.name.replace("android", "myappname")
.replace(".apk", "-" + getVersionName() + ".apk"))
}
}
}
}
}