android——利用gradle實現多渠道打包並自訂包名(umeng多渠道)

來源:互聯網
上載者:User

標籤:ges   channel   包名   xml檔案   and   asp   def   value   android   

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所在路徑:項目路徑\app\app-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)                }            }        }    }

 

android——利用gradle實現多渠道打包並自訂包名(umeng多渠道)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.