android{
compileSdkVersion 28
defaultConfig {
applicationId "com.exemple.xx"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
//在apk文件後邊生成版本號信息
android.applicationVariants.all {
variant ->variant.outputs.all {
outputFileName = "app_"+ buildType.name + "_v${defaultConfig.versionName}-${releaseTime()}.apk"
}
}
}
//在android {} 方法外面
def releaseTime() {
return new Date().format("yyyyMMddHHmmss", TimeZone.getDefault())
}