Created
January 17, 2017 05:06
-
-
Save Dhaval2404/2f6df6db5e33c55e28d272e0eab11856 to your computer and use it in GitHub Desktop.
Change build apk file name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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