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等新功能都无法正常使用 ...
随机推荐
- 使用json.dumps转换django queryset的datatime报错问题解决
转换成json时使用的方法如下: json.dumps(list(models.userlist.objects.values("vu"))) 报错信息如下: Traceback ...
- PHP 伪协议
1.file:// file://用于访问本地文件系统,不受allow_url_fopen影响 <?php include($_GET['file']); ?> 2.http:// GET ...
- umount命令详解
基础命令学习目录首页 umount 用来卸载设备 -a:卸除/etc/mtab中记录的所有文件系统: -h:显示帮助: -n:卸除 ...
- javaweb 安全传输签名机制
java web传输中的安全签名说明: 对请求中的数据 Key对进行签名,最终生成一个签名字符串,标记为sign:"djflw8wejwl9w0ejwlush8fw9ew9",位数 ...
- Node.js中exports,module.exports以及require方法
在Node.js中,使用module.exports.f = ...与使用exports.f = ...是一样的,此时exports就是module.exports的一种简写方式.但是,需要注意的是, ...
- 欢迎来怼--第二十九次Scrum会议
一.小组信息 队名:欢迎来怼 小组成员 队长:田继平 成员:李圆圆,葛美义,王伟东,姜珊,邵朔,阚博文 小组照片 二.开会信息 时间:2017/11/17 15:55~16:25,总计30min. 地 ...
- Thunder-Final冲刺中间产物-2017秋-软件工程第十二次作业
Thunder-Final发布中间产物(WBS&PSP) WBS: 分解方式:按照「爱阅」阅读器的实施过程分解 使用工具:visio 2013 PSP: PSP 预期时间 Planning 计 ...
- RocEDU.阅读.写作选择书目
很高兴加入这样一个专门于读书.写作的群. 一.选择图书 通识类: <你的灯亮着吗> 作者: 高斯 (Donald C. Gause) / 温伯格 (Gerald M.Weinberg) 出 ...
- Leetcode题库——31.下一个排列
@author: ZZQ @software: PyCharm @file: nextPermutation.py @time: 2018/11/12 15:32 要求: 实现获取下一个排列的函数,算 ...
- mysql hibernate 关于默认值
字段的默认值 写 NOT NULL DEFAULT 0 等等 一直不行, 算了 干脆在创建的时候 在代码set好了 版权声明:本文为博主原创文章,未经博主允许不得转载.