Skip to content

Instantly share code, notes, and snippets.

@Dhaval2404
Created January 17, 2017 05:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Dhaval2404/2f6df6db5e33c55e28d272e0eab11856 to your computer and use it in GitHub Desktop.
Save Dhaval2404/2f6df6db5e33c55e28d272e0eab11856 to your computer and use it in GitHub Desktop.
Change build apk file name.
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def setOutputAPKName(applicationVariants) {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def SEPARATOR = "_"
def project = "AppName"
def buildType = variant.variantData.variantConfiguration.buildType.name
def versionName = "v" + variant.versionName
def versionCode = "c" + variant.versionCode
def date = new Date();
def formattedDate = date.format('ddMMyyyy_HHmm')
def newApkName = project + SEPARATOR + buildType + SEPARATOR + versionCode +
SEPARATOR + versionName +
SEPARATOR + formattedDate + ".apk"
output.outputFile = new File(output.outputFile.parent, newApkName)
}
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.dhaval2404"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
setOutputAPKName(applicationVariants)
}
debug {
setOutputAPKName(applicationVariants)
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
ext.androidSupportVersion = '25.0.1'
compile "com.android.support:appcompat-v7:$androidSupportVersion"
compile "com.android.support:design:$androidSupportVersion"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment