标签:
为了统计各个渠道的数据,例如下载量等统计,就要针对不同渠道打包。现在是用ant 打包的,觉得是时候换掉了。
开始打包:
1.在AndroidManifest.xml 中写上下面这段PlaceHolder
<meta-data android:name="ChannelName" android:value="${ChannelName}" />
2.在app的 build.gradle 设置productFlavors
productFlavors {
wandoujia {
manifestPlaceholders = [ChannelName: "wandoujia"]
}
baidu {
manifestPlaceholders = [ChannelName: "baidu"]
}
c360 {
manifestPlaceholders = [ChannelName: "c360"]
}
uc {
manifestPlaceholders = [ChannelName: "uc"]
}
}
默认的渠道名,我们可以在defaultConfig里定义
manifestPlaceholders = [ChannelName:"你想定义的默认渠道名"]
3.打包需要签名,在这里设置,如下图
设置完成后会在build.gradle 生成如下代码
signingConfigs {
config {
keyAlias ‘your_keyAlias‘
keyPassword ‘your_alias_password‘
storeFile file(‘your_keystore_path‘)
storePassword ‘your_keystore_password‘
}
}
4.运行,在Android studio 自带的Terminal 执行
gradlew assembleRelease
然后就喝杯水坐等打包完成,是不是很方便呢
标签:
原文地址:http://www.cnblogs.com/yema/p/4900389.html