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

 

All flavors must now belong to a named flavor dimension的更多相关文章

  1. Error:All flavors must now belong to a named flavor dimension.

    环境 android studio 3.0 错误 Error:All flavors must now belong to a named flavor dimension. 解决 在build.gr ...

  2. 安卓 android studio 报错 All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com

    这个问题是Android studio升级到3.0之后,运行的时候会提示gradle要升级到3.5版本才能编译.于是我把我的gradle升级到了 gradle-4.1-milestone-1 版本,是 ...

  3. 解决Error:All flavors must now belong to a named flavor dimension. Learn more at...

    低版本的gradle里面不会出现这个错误,高版本出现,不多说,看如何解决 在defaultConfig{}中添加:flavorDimensions "default" 保证所有的f ...

  4. 解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com

    主app的build.gradle里面的 defaultConfig { targetSdkVersion:*** minSdkVersion :*** versionCode:*** version ...

  5. 更新Android Studio 3.0碰到的问题

    更新完后试下运行正在维护的旧项目,出现各种错误,因为后来发现问题不在这,所以没记完整,大概如下: A larger heap for the Gradle daemon is recommended ...

  6. Android之友盟多渠道打包与数据统计

    文章大纲 一.多渠道打包与数据统计介绍二.友盟实现多渠道打包实战三.友盟数据统计实战四.项目源码下载五.参考文章   一.多渠道打包与数据统计介绍   多渠道打包,相信很多同学都知道.在Android ...

  7. Android Studio 常见问题及解决方法

    一.Error:All flavors must now belong to a named flavor dimension 问题描述: Error:All flavors must now bel ...

  8. 升级到 Android Studio 3.0 + Gradle 4.1 遇到的一些坑及解决方案

    问题一: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkD ...

  9. gradle tool升级到3.0注意事项

    Gradle版本升级 其实当AS升级到3.0之后,Gradle Plugin和Gradle不升级也是可以继续使用的,但很多新的特性如:Java8支持.新的依赖匹配机制.AAPT2等新功能都无法正常使用 ...

随机推荐

  1. Python科学测量与计算库Pymeasure: 控制你的仪器进行自动测试和科学计算

    Python这种脚本语言因其语法简单,工具包丰富成熟,使用起来非常方便.在很多领域被广泛使用,今天介绍的是python在仪器控制应用领域,python在仪器控制领域相关的书籍可以参考<真实世界的 ...

  2. 琴声不等式--jensen

    (来自百度百科) 1. 凹函数,不加权 2. 凹函数,加权 3. 凸函数,不加权 4. 凸函数,加权 应用 在EM算法Q函数的推导中,用到了第二个不等式(凹函数,加权)

  3. [Windows][C#][.NET][WPF]基于ArcFace2.0+红外双目摄像头的活体检测

    废话不多说 直接上图这个是demo中用到的双目摄像头,一个是红外的,一个是正常的rgb摄像头两个usb接口,在电脑上呈现两路摄像头通道程序检测RGB输出图像,当检测到有人脸时,用RGB人脸的位置到红外 ...

  4. dp算法之有代价的最短路径

    题目:有代价的最短路径 题目介绍:如下图所示,现在平面上有N个点,此时N=7,每个点可能和其他点相连,相连的线有一定权值,求出从0点到N-1点的消耗权值的最小值. 分析:用动态规划的思路来解决,每一点 ...

  5. 工程能力之C4模型

    概述 刚在InfoQ上看到一篇介绍C4Model的文章,觉得这个模型设计的很赞,很有指导意义,做个简单的记录. Why,为什么需要架构图? ThoughtWorks中国 文章中有几句话我觉得很有道理, ...

  6. redis高级应用(集群搭建、集群分区原理、集群操作)

    文章主目录 Redis集群简介 Redis集群搭建 Redis集群分区原理 集群操作 参考文档 本文是redis学习系列的第四篇,前面我们学习了redis的数据结构和一些高级特性,点击下面链接可回看 ...

  7. 导出excel失败,提示提示加载类型库/DDL出错

    首先,这里提供的解决办法仅适用于出现如下异常的情况:无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的 COM 对象强制转换为接口类型“M ...

  8. Notes of Daily Scrum Meeting(11.19)

    Notes of Daily Scrum Meeting(11.19) 现在工程项目进入尾声了,我们的项目中还有一些问题需要解决,调试修改起来进度比较慢,所以昨天就没有贴出项目 进度,今天的团队工作总 ...

  9. 45度炸队Alpha冲刺博客集

    博客集如下: Alpha冲刺Day1:第一天冲刺记录 Alpha冲刺Day2:第二天冲刺记录 Alpha冲刺Day3:第三天冲刺记录 Alpha冲刺Day4:第四天冲刺记录 Alpha冲刺Day5:第 ...

  10. 文件名命工具类(将指定目录下的文件的type类型的文件,进行重命名,命名后的文件将去掉type)

    import java.io.File; /** * <b>function:</b> 文件命名工具类 * @author hoojo * @createDate 2012-5 ...