这个问题是Android studio升级到3.0之后,运行的时候会提示gradle要升级到3.5版本才能编译。于是我把我的gradle升级到了
 gradle-4.1-milestone-1 版本,是2017年7月份最新版本了。
于是我把主程序的build.gradle中的gradle版本改成了这个,具体指定哪个版本我也不知道,于是就写了个3.0+

 dependencies {
classpath 'com.android.tools.build:gradle:3.0+'
}

然后再次编译,又发现了毒。
提示:Error:All flavors must now belong to a named flavor dimension.Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

报错截图:

这个一个错误,意思是:所有的flavors都必须属于同一个风格。
去翻墙看了它提供的地址才知道:
 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:
Error:All flavors must now belong to a named flavor dimension.
The flavor 'flavor_name' is not assigned to a flavor dimension.

To resolve this error, assign each flavor to a named dimension, as shown in the sample below. Because dependency matching is now taken care of by the plugin, you should name your flavor dimensions carefully. For example, if all your app and library modules use the foo dimension, you'll have less control over which flavors are matched by the plugin. 
// 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"
...
}
}

大致是说,Plugin 3.0.0之后有一种自动匹配消耗库的机制,便于debug variant 自动消耗一个库,然后就是必须要所有的flavor 都属于同一个维度。
为了避免flavor 不同产生误差的问题,应该在所有的库模块都使用同一个foo尺寸。
= 。=还是懵逼。说一堆依然不是很理解。
但是我们从中已经知道解决方案了:
在主app的build.gradle里面的
defaultConfig {
    targetSdkVersion:***
    minSdkVersion :***
    versionCode:***
    versionName :***
    //版本名后面添加一句话,意思就是flavor dimension 它的维度就是该版本号,这样维度就是都是统一的了
    flavorDimensions "versionCode"
}

就直接解决这个问题。然后app 就可以happy的运行起来了。

文章原链接:https://blog.csdn.net/syif88/article/details/75009663/

安卓 android studio 报错 All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com的更多相关文章

  1. 解决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 ...

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

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

  3. 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/ ...

  4. 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 ...

  5. 安卓 android studio 报错 Lint found fatal errors while assembling a release target

    报错截图如下: 解决方法:在app的build.gradle中添加如下代码 android{ lintOptions { checkReleaseBuilds false abortOnError f ...

  6. 安卓 android studio 报错 The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle

    今天将项目迁移到另一台笔记本,进行build出现以下问题,导致build失败 报错截图: 大致意思,目前使用的build工具版本27.0.3不合适.因为当前使用Gradle插件版本是3.2.1,这个版 ...

  7. 安卓 android studio 报错 Unknown host 'jcenter.bintray.com'. You may need to adjust the proxy settings in Gradle.

    报错截图: 问题原因:因为build.gradle中jcenter()或者maven()被墙了,所以会出现这种情况. 解决方案:(我的gradle版本是:classpath 'com.android. ...

  8. 安卓 android studio 报错 WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and

    报错截图: 问题原因:compile会被在2018年底取消,会被imlementation替代,所以会报这个警告,解决警告的方式就是换成 imlementation 就好了 解决方法: 在 app 的 ...

  9. 安卓 android studio 报错 Could not find com.android.tools.build:gradle:3.2.1.

    报错截图如下: 解决方法:在project的builde.gradle做如下操作分别加上google()

随机推荐

  1. 基于h5+的微信登录,hbuilder打包

    1.打开app项目的manifest.json的文件,选择模块权限配置,将OAuth(登录鉴权)模块添加至已选模块中 2.选择SDK配置,在plus.oauuth·登录鉴权中,勾选□ 微信登录,配置好 ...

  2. SVM: 直观上理解大间距分类器

    在SVM中,增加安全的间距因子 那么增加了这个间距因子后,会出现什么样的结果呢,我们将C设置为很大(C=100000) SVM决策边界 当我们将C设置得很大进,要想SVM的cost function最 ...

  3. 任何人都适合的常用Chrome插件(工欲善其事必先利其器)

    1.划词翻译 介绍链接:http://t.cn/RqpoGU4 下载地址: Chrome 应用商店(请翻墙). 下载 .crx 安装包手动安装 功能如下: - 支持几乎所有语言的翻译与阅读,并且同时支 ...

  4. Python数据分析(基础)

    目录: Python基础: Python基本用法:控制语句.函数.文件读写等 Python基本数据结构:字典.集合等 Numpy:简述 Pandas:简述 一. Python基础: 1.1 文件读取 ...

  5. LightOJ - 1336 - Sigma Function(质数分解)

    链接: https://vjudge.net/problem/LightOJ-1336 题意: Sigma function is an interesting function in Number ...

  6. composer 发布一个自己的扩展包

    练习写了一个扩展包,步骤参考github项目的readme.md 文件.https://github.com/codingmonkey9/test 说明:只是自己简单记录一下,没有详细写. 如何发布具 ...

  7. S1_搭建分布式OpenStack集群_01 准备虚拟机

    Openstack版本:openstack-queen 版本 一.环境准备 网络规划: Management + API Network:10.10.11.0/24 eth1    网桥:br1 VM ...

  8. 搭建使用PHPstorm环境

    本周学习内容: 1.学习PHP: 2.复习技能表: 3.学习正则表达式: 实验内容: 1.安装PHPstorm环境,破解PHPstorm: 2.PHPstorm运行PHP代码 3.PHPstorm安装 ...

  9. learning java AWT 布局管理器FlowLayout

    AWT提供了FlowLayout   从左到右排列所有组件,遇到边界就会折回下一行重新开始. import java.awt.*; public class FlowLayoutTest { publ ...

  10. Ubuntu 下面手动安装 Redis

    1.下载 wget http://download.redis.io/releases/redis-2.8.17.tar.gz .tar.gz cd redis- make 2.复制文件到bin目录 ...