AndroidStudio3.0下使用多渠道打包
1. 在AndroidManifest.xml下配置
<meta-data
android:name="CHANNEL"
android:value="${CHANNEL_VALUE}" />
2. 在build.gradle设置productFlavors
android {
productFlavors {
polobe {
manifestPlaceholders = [CHANNEL_VALUE: "polobe"]
}
wangtent {
manifestPlaceholders = [CHANNEL_VALUE: "wangtent"]
}
}
productFlavors.all {
flavor -> flavor.manifestPlaceholders = [CHANNEL_VALUE: name]
}
}
3. 编译,报毒
Error:All flavors must now belong to a named flavor dimension.Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
4. 解决方案
在主app的build.gradle里面添加
defaultConfig {
applicationId "com.xxx.xxxxxx"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//以下为添加的内容
flavorDimensions "versionCode"
//以上为添加的内容
}