时间:2021-05-21
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上进行多渠道打包时编译时出现这个错误
多渠道打包参考:
解决问题参考: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
void flavorDimensions(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 versionCode 30000 + android.defaultConfig.versionCode versionNameSuffix "-minApi24" ... } minApi23 { dimension "api" minSdkVersion '23' versionCode 20000 + android.defaultConfig.versionCode versionNameSuffix "-minApi23" ... } minApi21 { dimension "api" minSdkVersion '21' versionCode 10000 + android.defaultConfig.versionCode versionNameSuffix "-minApi21" ... } }好了,这就是官方给出的gradle多渠道打包的方式
总结
以上所述是小编给大家介绍的Android studio 3.0上进行多渠道打包遇到的问题小结(超简洁版),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1.替换符的使用(1)在app-android-defaultConfig(或者多渠道打包)下面可以这样使用android{defaultConfig{mani
1、什么是多渠道打包 在不同的应用市场可能有不同的统计需求,需要为每个应用市场发布一个安装包,这里就引出了Android的多渠道打包。在安装包中添加不同的标识
本文介绍了Android多渠道打包的方法步骤,分享给大家,具体如下:1.生成签名文件点击Build->GenerateSignedAPK:2.创建一个签名红色填
由于国内Android市场众多渠道,为了统计每个渠道的下载及其它数据统计,就需要我们针对每个渠道单独打包,如果让你打几十个市场的包岂不烦死了,不过有了Gradl
多渠道打包变更flavorDimensions"default"productFlavors{xxxx{dimension"default"}}productF