解决Error:All flavors must now belong to a named flavor dimension

简介: 前言最近写的项目越来越大,出现了64K问题,所以用了Multidex来突破64K方法数限制,然后为了优化编译速度在build.gradle文件中加入了如下代码productFlavors { // Define separate dev and prod product flavors.

前言

最近写的项目越来越大,出现了64K问题,所以用了Multidex来突破64K方法数限制,然后为了优化编译速度在build.gradle文件中加入了如下代码

productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 18
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 16
        }
    }

可是编译后却出现了如下问题。


img_fe0c66b0f1cb2141cf97cd7856c7e480.png

出现的原因

经过在网上查阅资料发现是因为Plugin 3.0.0之后有一种自动匹配消耗库的机制,便于debug variant 自动消耗一个库,然后就是必须要所有的flavor 都属于同一个维度。为了避免flavor 不同产生误差的问题,应该在所有的库模块都使用同一个foo尺寸。

解决问题

在主app的build.gradle里面的进行修改。

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

个人技术博客:https://myml666.github.io

目录
相关文章
|
4月前
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
60 5
|
Linux
ERROR: 2 matches found based on name: network product-server_default is ambiguous
ERROR: 2 matches found based on name: network product-server_default is ambiguous
143 0
成功解决ValueError: Found input variables with inconsistent numbers of samples: [86, 891]
成功解决ValueError: Found input variables with inconsistent numbers of samples: [86, 891]
|
TensorFlow 算法框架/工具
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
258 0
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
Duplicate methods named spliterator with the parameters () and () are inherited from the types Colle
Duplicate methods named spliterator with the parameters () and () are inherited from the types Colle
67 0
|
应用服务中间件 Android开发
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
128 0
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
成功解决KeyError: “Passing list-likes to .loc or [] with any missing labels is no longer supported. The
成功解决KeyError: “Passing list-likes to .loc or [] with any missing labels is no longer supported. The
|
Android开发
【错误记录】Gradle 配置 productFlavors 报错 ( All flavors must now belong to a named flavor dimension. )
【错误记录】Gradle 配置 productFlavors 报错 ( All flavors must now belong to a named flavor dimension. )
391 0
|
Java Apache
Failed to place enough replicas
如果DataNode的dfs.datanode.data.dir全配置成SSD类型,则执行“hdfs dfs -put /etc/hosts hdfs:///tmp/”时会报如下错误: 2017-05-04 16:08:22,545 WARN org.
3271 0