Android studio 3.0上进行多渠道打包遇到的问题小结(超简洁版)

Android studio 3.0上进行多渠道打包遇到的问题小结(超简洁版),第1张

概述Error:Allflavorsmustnowbelongtoanamedflavordimension.Theflavor\'xiaomi\'isnotassignedtoaflavordimension.Learnmoreathttps://d.android.com/r/tools/flavorDimensions-missing-error-message.html

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

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上进行多渠道打包遇到的问题小结(超简洁版)全部内容,希望文章能够帮你解决Android studio 3.0上进行多渠道打包遇到的问题小结(超简洁版)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1144017.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存