Inside the android Tag
applicationVariants.all { variant ->
variant.outputs.all {
def PROJECT_NAME = "male-app"
def SEP = "_"
def buildType
if (variant.buildType.name == "release") {
buildType = "production"
} else {
buildType = "test"
}
def version = "v" + variant.versionName
def date = new Date()
def formattedDate = date.format('yyyyMMdd')
def newApkName = PROJECT_NAME + SEP + buildType + SEP + version + SEP + formattedDate + ".apk"
outputFileName = newApkName
}
}