• android——利用gradle实现多渠道打包并自定义包名(umeng多渠道)


    1.首先在mainfest.xml文件中,给umeng_channel设置一个变量“${UMENG_CHANNEL_VALUE}

    2.在gradle中,配置flavors。

     productFlavors {
            yingyongbao {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_txyyb"]
          
            }
            s360 {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_360"]
           
            }
            baidu {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_baidu"]
         
            }
            xiaomi {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_xiaomi"]
               
            }
            huawei {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_huawei"]
              
            }
            meizu {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_meizu"]
              
            }
            lenovo {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_len"]
                applicationId 'com.songheng.beijingtianqikuaibao'
            }
            oppo {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_oppo"]
    
            }
            vivo {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_vivo"]
    
            }
            ali {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_ali"]
    
            }
            yingyonghui {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_yyh"]
    
            }
            sougou {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_sougou"]
    
            }
            anzhi {
                manifestPlaceholders = [UMENG_CHANNEL_VALUE: "bjtq_anzhi"]
            }
        }

    3.可以直接签名打包了。

    这么打包,apk所在路径:项目路径appapp-anzhi-release.apk 

    4.自定义包名方式

      applicationVariants.all { variant ->
            variant.outputs.each { output ->
                if ('release'.equals(variant.buildType.name)) {
                    def outputFile = output.outputFile
                    if (outputFile != null && outputFile.name.endsWith('.apk')) {
    
                        def buildLable = ""
                        def buildName = ""
    
                        // 是否是连接测试服务器版本
                        if (rootProject.hasProperty('TestServer')) {
                            buildLable = "${buildLable}_Test"
                        } else {
                            buildLable = "${buildLable}_Product"
                        }
                //buildname 是channel名称
                        variant.productFlavors.each { product ->
                            buildName = product.name
                        }
    
                        // 是否是testin版本
                        if (rootProject.hasProperty('TestIn')) {
                            buildLable = "${buildLable}_TestIn"
                        }
                        def productName = "bjtqyb"
                        def fileName = "${productName}_v${defaultConfig.versionName}_${releaseTime()}${buildLable}_${buildName}.apk"
                        output.outputFile = new File("${rootDir}/outapks/", fileName)
                    }
                }
            }
        }
  • 相关阅读:
    使用docker搭建gitlab版本控制系统
    Spring Boot与Docker部署
    CentOS7 使用yum命令安装Java SDK(openjdk)
    配置带用户权限的docker registry v2
    Docker搭建带有访问认证的私有仓库
    CentOS7 关闭防火墙
    CentOS7.2网络配置
    Docker Machine 简介
    docker的常用命令汇总
    实时查看docker容器日志
  • 原文地址:https://www.cnblogs.com/shoneworn/p/7722936.html
Copyright © 2020-2023  润新知