Skip to content

Instantly share code, notes, and snippets.

@piyush-malaviya
Created September 5, 2019 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piyush-malaviya/1652f8450675a0465e6c3c5d59ded149 to your computer and use it in GitHub Desktop.
Save piyush-malaviya/1652f8450675a0465e6c3c5d59ded149 to your computer and use it in GitHub Desktop.
android {
...
buildTypes {
release {
minifyEnabled true
...
}
debug {
minifyEnabled false
}
}
productFlavors {
prod {
applicationId "com.example.myproject"
versionCode 3
versionName "1.2.0"
}
dev {
applicationId "com.example.myproject.dev"
versionCode 15
versionName "1.3.6"
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "myProject"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def version = variant.versionName
def date = new Date();
def formattedDate = date.format('ddMMyy_HHmm')
def newApkName = project + SEP + flavor + SEP + buildType + SEP + version + SEP + formattedDate + ".apk"
outputFileName = new File(newApkName)
}
}
}
android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent,
output.outputFile.name.replace(".apk", "-${variant.versionName}.apk"))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment