Android Studio 如何自定义导出apk文件名

来源:互联网 发布:gta5最漂亮的捏脸数据 编辑:程序博客网 时间:2024/05/21 03:24

Android Studio默认打包输出apk文件名为app-release或者app-debug,不便分类,所以需要对输出配置进行修改,使输出的apk带有版本信息和日期.

配置build.gradle

    android.applicationVariants.all { variant ->        variant.outputs.each { output ->            def releaseTime = new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))            def file = output.outputFile            def filename = "Version_"+defaultConfig.versionName+"_"+releaseTime+".apk"            output.outputFile = new File(file.parent, filename)        }    }
0 0
原创粉丝点击