美文网首页
Android自定义打包apk名字

Android自定义打包apk名字

作者: 啤酒小龙虾 | 来源:发表于2018-04-23 16:27 被阅读0次

AS3.0以前

在app的  build.gradle中 android {}里面添加以下代码

//自定义打包apk名字

android.applicationVariants.all { variant ->

        variant.outputs.each { output ->

            output.outputFile =new File(output.outputFile.parent,"名字" +"-" + buildType.name +"-v" +

                            defaultConfig.versionName  +".apk");

        }

}

AS3.0以后

applicationVariants.all { variant ->

        variant.outputs.all { output ->

        def outputFile = output.outputFile

            if (outputFile !=null && outputFile.name.endsWith('.apk')) {

                  def fileName = "自定义包名" + "-" + buildType.name + "-v" + defaultConfig.versionName + ".apk"

                outputFileName = fileName

            }

        }

}

 buildType.name //获取的是 正式版 还是测试版

defaultConfig.versionName // 获取的是版本号

相关文章

网友评论

      本文标题:Android自定义打包apk名字

      本文链接:https://www.haomeiwen.com/subject/jzellftx.html