itgoyo / AndroidSummary

12 stars 4 forks source link

Android studio 打包自定义命名 apk #103

Open itgoyo opened 5 years ago

itgoyo commented 5 years ago

1,build.gradle  根目录

def releaseTime() {
    return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}

2,android { } 节点中添加

android.applicationVariants.all { variant ->
    variant.outputs.all {
        outputFileName = "apk名字" +
                "${defaultConfig.versionName}_${variant.buildType.name}_${releaseTime()}.apk"

    }
}

3, 打包完的 apk:

apk 名字 1.0_debug_2019-09-05.apk