首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Android studio 3.0上进行多渠道打包遇到的问题

Error:All flavors must now belong to a named flavor dimension. The flavor ‘xiaomi’ is not assigned to a flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

Android studio 3.0上进行多渠道打包时编译时出现这个错误

多渠道打包参考:http://blog.csdn.net/mynameishuangshuai/article/details/51783303

解决问题参考:https://stackoverflow.com/questions/44105127/android-studio-3-0-flavor-dimension-issue

多渠道打包的细节我就不说了,参考网络上的,或者我上面的这个链接就好,下面给出一下我修改的代码(如果有其他的改法也希望能多多交流)

flavorDimensions"default"

productFlavors {

kuan{

dimension"default"

manifestPlaceholders = [UMENG_CHANNEL_VALUE:"kuan"]

}

xiaomi {

dimension"default"

manifestPlaceholders = [UMENG_CHANNEL_VALUE:"xiaomi"]

}

qh360 {

dimension"default"

manifestPlaceholders = [UMENG_CHANNEL_VALUE:"qh360"]

}

baidu {

dimension"default"

manifestPlaceholders = [UMENG_CHANNEL_VALUE:"baidu"]

}

wandoujia {

dimension"default"

manifestPlaceholders = [UMENG_CHANNEL_VALUE:"wandoujia"]

}

}

或者:

flavorDimensions"default"

productFlavors {

kuan{dimension"default"}

xiaomi {dimension"default"}

qh360 {dimension"default"}

baidu {dimension"default"}

wandoujia {dimension"default"}

}

productFlavors.all {

flavor-> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]

}

然后解决问题之后我又去官网查阅了一下,地址如下:

https://developer.android.com/studio/build/build-variants.html#flavor-dimensions

根据官网说法:

You must assign each product flavor you configure to one of the flavor dimensions.

你必须指定一种 flavor dimensions

voidflavorDimensions(String... dimensions)

flavorDimensions 后面可以添加多个不同类型的参数例如:

flavorDimensions"api","mode"

接下来的使用对应起来就好了:

productFlavors {

demo {

// Assigns this product flavor to the "mode" flavor dimension.

dimension"mode"

...

}

full {

dimension"mode"

...

}

// Configurations in the "api" product flavors override those in "mode"

// flavors and the defaultConfig {} block. Gradle determines the priority

// between flavor dimensions based on the order in which they appear next

// to the flavorDimensions property above--the first dimension has a higher

// priority than the second, and so on.

minApi24 {

dimension"api"

minSdkVersion'24'

// To ensure the target device receives the version of the app with

// the highest compatible API level, assign version codes in increasing

// value with API level. To learn more about assigning version codes to

// support app updates and uploading to Google Play, read Multiple APK Support

versionCode30000+ android.defaultConfig.versionCode

versionNameSuffix"-minApi24"

...

}

minApi23 {

dimension"api"

minSdkVersion'23'

versionCode20000+ android.defaultConfig.versionCode

versionNameSuffix"-minApi23"

...

}

minApi21 {

dimension"api"

minSdkVersion'21'

versionCode10000+ android.defaultConfig.versionCode

versionNameSuffix"-minApi21"

...

}

}

好了,这就是官方给出的gradle多渠道打包的方式

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180412B1TJC600?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券