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
All flavors must now belong to a named flavor dimension的更多相关文章
- 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 ...
- 安卓 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 版本,是 ...
- 解决Error:All flavors must now belong to a named flavor dimension. Learn more at...
低版本的gradle里面不会出现这个错误,高版本出现,不多说,看如何解决 在defaultConfig{}中添加:flavorDimensions "default" 保证所有的f ...
- 解决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 ...
- 更新Android Studio 3.0碰到的问题
更新完后试下运行正在维护的旧项目,出现各种错误,因为后来发现问题不在这,所以没记完整,大概如下: A larger heap for the Gradle daemon is recommended ...
- Android之友盟多渠道打包与数据统计
文章大纲 一.多渠道打包与数据统计介绍二.友盟实现多渠道打包实战三.友盟数据统计实战四.项目源码下载五.参考文章 一.多渠道打包与数据统计介绍 多渠道打包,相信很多同学都知道.在Android ...
- Android Studio 常见问题及解决方法
一.Error:All flavors must now belong to a named flavor dimension 问题描述: Error:All flavors must now bel ...
- 升级到 Android Studio 3.0 + Gradle 4.1 遇到的一些坑及解决方案
问题一: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkD ...
- gradle tool升级到3.0注意事项
Gradle版本升级 其实当AS升级到3.0之后,Gradle Plugin和Gradle不升级也是可以继续使用的,但很多新的特性如:Java8支持.新的依赖匹配机制.AAPT2等新功能都无法正常使用 ...
随机推荐
- RAID卡的结构详解
软件RAID的缺点如此之多,使人们不断地思考更多实现RAID的方法.既然软件缺点太多,那么用硬件实现如何呢? RAID卡就是一种利用独立硬件来实现RAID功能的方法.要在硬件上实现RAID功能,必须找 ...
- 基于KVM的H3C云计算平台CAS运维经验
- LEETCODE —— Unique Paths II [Dynamic Programming]
唯一路径问题II Unique Paths II Follow up for "Unique Paths": Now consider if some obstacles are ...
- The Art of Multiprocessor Programming读书笔记 (更新至第3章)
这份笔记是我2013年下半年以来读“The Art of Multiprocessor Programming”这本书的读书笔记.目前有关共享内存并发同步相关的书籍并不多,但是学术文献却不少,跨越的时 ...
- 随手记录-linux-常用命令
转自:https://www.cnblogs.com/yjd_hycf_space/p/7730690.html linux目录结构:http://www.cnblogs.com/fat39/p/72 ...
- 20135234mqy 实验三:敏捷开发与XP实践
实 验 报 告 课程:Java 班级: 1352 姓名:mqy 学号:20135234 成绩: 指导教师:娄嘉鹏 实验日期:2015. ...
- JAVA实验报告三:敏捷开发与XP实践
实验内容 1. XP基础 2. XP核心实践 3. 相关工具 实验步骤 (一)敏捷开发与XP 软件工程是把系统的.有序的.可量化的方法应用到软件的开发.运营和维护上的过程.软件工程包括下列领域:软件需 ...
- Spring笔记①--helloworld
Spring Spring是一个轻量级控制反转(IoC)和面向切面(AOP)的容器框架,它主要是为了解决企业应用开发的复杂性而诞生的: 目的:解决企业应用开发的复杂性 功能:使用基本的Javabean ...
- Internet 校验和的数学性质
Internet 校验和(Checksum)仅计算头部的正确性,这一点很重要,这意味着 IP 协议不检查 IPv4 packet 有效载荷部分的数据正确性.为了保证有效载荷部分的正常传输,其他协议必须 ...
- [建树(非二叉树)] 1090. Highest Price in Supply Chain (25)
1090. Highest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors ...