Android Studio3.0 gradle 重命名apk


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())
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章