1. First, in the Mainfest.xml file, set a variable "${umeng_channel_value}" to Umeng_channel
2. In Gradle, configure the 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. It can be signed and packaged directly.
So packed, apk path: Project Path \app\app-anzhi-release.apk
4. custom package Name mode
Applicationvariants.all {variant-Variant.outputs.each {Output-if(' Release '. Equals (Variant.buildType.name)) {def outputFile=Output.outputfileif(OutputFile! =NULL&& outputFile.name.endsWith ('. apk ')) {def buildlable= ""def Buildname= ""//is the connection test server version if(Rootproject.hasproperty (' TestServer ') ) {buildlable= "${buildlable}_test" } Else{buildlable= "${buildlable}_product"}//buildname is the channel name Variant.productFlavors.each {Product-Buildname=Product.name}//whether it is a testin version if(Rootproject.hasproperty (' Testin ') ) {buildlable= "${buildlable}_testin"} def productName= "Bjtqyb"def FileName= "${productname}_v${defaultconfig.versionname}_${releasetime ()}${buildlable}_${buildname}.apk"Output.outputfile=NewFile ("${rootdir}/outapks/", FileName)} } } }
android--leveraging Gradle for multi-channel packaging and Customizing package names (Umeng multi-Channel)