zoukankan      html  css  js  c++  java
  • All flavors must now belong to a named flavor dimension

    FAQ:

    All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

    解决:

    看官方文档:

    Plugin 3.0.0 includes a new dependency mechanism that automatically matches variants when consuming a library. This means an app's debug variant automatically consumes a library's debug variant, and so on. It also works when using flavors—an app's redDebug variant will consume a library's redDebug variant. To make this work, the plugin now requires that all flavors belong to a named flavor dimension —even if you intend to use only a single dimension. Otherwise, you will get the following build error:

    2.Flavor Dimensions变更

    Android Plugin3.0的依赖机制:在使用library时会自动匹配variant(debug, release),就是说app的debug会自动匹配library的debug,相信大多数人也像我一样,当library多了,不会手动选择每个Library的variant。现在好了,它会自动匹配了。同样如果使用flavor的时候,比如app的redDebug同样会自动匹配library的readDebug。虽然有这样的优势,但是在使用flavor时,必须定义flavor dimension,否则会提示错误:

    Error:All flavors must now belong to a named flavor dimension.
    The flavor 'flavor_name' is not assigned to a flavor dimension.
    • 这个错误,我也已经在使用Android Studio3.0以后碰到好多次了。现在使用flavor,必须像下面一样配置:
    // Specifies a flavor dimension.
    flavorDimensions "color"
    
    productFlavors {
         red {
          // Assigns this product flavor to the 'color' flavor dimension.
          // This step is optional if you are using only one dimension.
          dimension "color"
          ...
        }
    
        blue {
          dimension "color"
          ...
        }
    }
    • 注意:如果library有两个dimensions:color,shape,但是app只有color,那么会如下的编译错误:
    Error:Could not resolve all dependencies for configuration ':bar:redDebugCompileClasspath'.
    Cannot choose between the following configurations on project :foo:
      - redCircleDebugApiElements
      - redSquareDebugApiElements
      ...
    • 在APP使用flavorSelection选定使用某个flavor dimension,注意如下配置:
    android {
      ...
      // The flavorSelection property uses the following format:
      // flavorSelection 'dimension_name', 'flavor_name'
    
      // Chooses the 'square' flavor from libraries that specify a 'shape'
      // dimension.
      flavorSelection 'shape', 'square'
    }

    ref docs:
    迁移到Android Studio 3.0
    http://blog.csdn.net/ncuboy045wsq/article/details/73521856
    https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

     
  • 相关阅读:
    JS数组常用方法参考---5、sort方法
    JS数组常用方法---1、课程介绍
    JS数组常用方法参考---4、unshift方法
    JS数组常用方法参考---3、队列对应的方法
    ES6课程---12、面向对象
    legend3---30、不同类型的网站打包方案
    数据库Sharding的基本思想和切分策略
    用sharding技术来扩展你的数据库(一)sharding 介绍
    什么是Scale Up和Scale Out?
    淘宝网采用什么技术架构来实现网站高负载的
  • 原文地址:https://www.cnblogs.com/bluestorm/p/7374903.html
Copyright © 2011-2022 走看看