Learn more at https://d.android.com

因为我把主程序的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.html

 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"android

productFlavors {
red {
// Assigns this product flavor to the 'color' flavor dimension.
// This step is optional if you are using only one dimension.
dimension "color"
...
}app

blue {
  dimension "color"
  ...
}

}less

大体是说,Plugin 3.0.0以后有一种自动匹配消耗库的机制,便于debug variant 自动消耗一个库,而后就是必需要全部的flavor 都属于同一个维度。
为了不flavor 不一样产生偏差的问题,应该在全部的库模块都使用同一个foo尺寸。
= 。=仍是懵逼。说一堆依然不是很理解。
可是咱们从中已经知道解决方案了:
在主app的build.gradle里面的
 defaultConfig {
 targetSdkVersion:
minSdkVersion :

versionCode:
 versionName :

//版本名后面添加一句话,意思就是flavor dimension 它的维度就是该版本号,这样维度就是都是统一的了
flavorDimensions "versionCode"
}ide

就直接解决这个问题。而后app 就能够happy的运行起来了gradle

相关文章
相关标签/搜索