打包配置:https://www.jianshu.com/p/afdaba526d33
AndroidManifest.xml 里设置动态渠道变量
<meta-data
android:name="UMENG_CHANNEL"
android:value="${UMENG_CHANNEL_VALUE}" />
在 build.gradle 设置 productFlavors , 这里假定我们需要打包的渠道为360、百度。
android {
...
productFlavors {
qh360 {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "qh360"]
}
baidu {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"]
}
}
...
}
或者批量修改
android {
productFlavors {
qh360 {}
baidu {}
}
productFlavors.all {
flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
}
android stuido 3.0新增:在app/gradle文件中加上 flavorDimensions 'versionCode' 否则会报错All flavors must now belong to a named flavor dimension。
android {
...
flavorDimensions 'versionCode'
...
}
productFlavors {
qh360 {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "xiaomi"]
dimension "channel"
}
baidu {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"]
dimension "channel"
}
}
打包APK
生成的APK
网友评论