1. 程式人生 > >Studio自定義釋出APK 名字

Studio自定義釋出APK 名字

最終的apk格式為 test-20170630-release-v1.0-1.apk

1 、修改build.grade

在android{}內新增

android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def outputFile = output.outputFile
        if (outputFile != null && outputFile.name.endsWith('.apk')) {
            //這裡修改apk檔名
//def fileName = "news7001.apk" def fileName ="test-"+releaseTime()+ "-" + buildType.name + "-v" + defaultConfig.versionName + "-" + defaultConfig.versionCode + ".apk" output.outputFile = new File(outputFile.parent, fileName) } } }
在android{}外新增
def releaseTime() {

    return new 
Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC")) }
如果需要修改釋出名字 直接修改 def filenam = **** 就可以了。

2、釋出程式

bulid->Genereta signed apk