所有com.android.support库必须使用完全相同的版本 [英] All com.android.support libraries must use the exact same version

查看:1980
本文介绍了所有com.android.support库必须使用完全相同的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将我的android studio从2.2.3版本更新到2.3时,突然在依赖关系中的第一个编译行中的build.gradle中出现了此错误。
$ b

(它没有关系哪个依赖关系会在第一个地方,但它总是会给我这个错误):

lockquote

所有com.android.support库必须使用完全相同的版本规范(混合版本可能会导致运行时崩溃)。发现版本25.2.0,24.0.0。示例包括com.android.support:animated-vector-drawable:25.2.0和com.android.support:mediarouter-v7:24.0.0

我查看了整个项目,找不到24.0.0版本的任何用法(我用ctrl + shift + F查看了整个项目)



这是我的build.gradle:

  android {
compileSdkVersion 25
buildToolsVersion '25 .0 .2'
useLibrary'org.apache.http.legacy'

defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionName1.0
versionCode 1
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules .txt'
}
debug {
minifyEnabled true
shrinkResources true
}
}
dexOptions {
javaMaxHeapSize4g
}
}

依赖关系{
编译fileTree(包括:['* .jar'] ,dir:'libs')
compile'c​​om.android.support:appcompat-v7:25.2.0'
compile'c​​om.google.android.gms:play-services:+'
编译'com.squareup:otto:1.3.8'
compile'c​​om.mcxiaoke.volley:library-aar:1.0.0'
compile'c​​om.android.support:multidex:1.0.1 '
}


解决方案


我已经浏览了整个项目,并且找不到任何24.0.0版本的使用方法。


它是作为一个传递依赖于你的其他依赖之一。

首先,将其他问题修复到你的 build.gradle 文件中,因为他们也可以解决这个问题:


  • 不要使用 + 为一个库版本。使用特定版本。

  • 使用特定的依赖关系用于您想要的Play Services SDK的特定部分。 play-services 带来了Play服务的所有,使您的应用程序比需要的大得多,并且减慢了您的构建时间。 / b>
  • 将官方的Volley工具( com)替换为 com.mcxiaoke.volley 如果所有这些都不清楚的话,该问题可以运行Gradle依赖关系报告来查看完整的依赖关系树。从那里,你会看到你的哪一个库需要不同版本的Android支持库。无论它要求什么,你都可以直接使用 25.2.0 版本请求它,或者使用Gradle的其他冲突解决方法来安排获取相同的版本。


    When i updated my android studio today from version 2.2.3 to 2.3 i suddenly got this error in my build.gradle on the first compile line in dependencies

    (It doesnt matter which dependencie will be at the first place but it will always give me this error):

    All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.2.0, 24.0.0. Examples include com.android.support:animated-vector-drawable:25.2.0 and com.android.support:mediarouter-v7:24.0.0

    i have looked through my entire project and i can not find any usage of versions 24.0.0 (I have looked with ctrl + shift + F to search in entire project)

    this is my build.gradle:

    android {
        compileSdkVersion 25
        buildToolsVersion '25.0.2'
        useLibrary 'org.apache.http.legacy'
    
        defaultConfig {
            minSdkVersion 16
            targetSdkVersion 25
            versionName "1.0"
            versionCode 1
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
            debug {
                minifyEnabled true
                shrinkResources true
            }
        }
        dexOptions {
            javaMaxHeapSize "4g"
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.android.support:appcompat-v7:25.2.0'
        compile 'com.google.android.gms:play-services:+'
        compile 'com.squareup:otto:1.3.8'
        compile 'com.mcxiaoke.volley:library-aar:1.0.0'
        compile 'com.android.support:multidex:1.0.1'
    }
    

    解决方案

    i have looked through my entire project and i can not find any usage of versions 24.0.0

    It is coming as a transitive dependency from one of your other dependencies.

    First, though, fix the other issues in your build.gradle file, as they may clear up this problem as well:

    • Do not use + for a library version. Use a specific version.

    • Do not use play-services. Use the specific dependencies for the specific pieces of the Play Services SDK that you want. play-services brings in all of Play Services, making your app much bigger than it needs to be and slowing down your build times a lot.

    • Replace com.mcxiaoke.volley with the official Volley artifact (com.android.volley:volley:1.0.0)

    If none of those clear up the issue, you can run a Gradle dependency report to see what your full tree of dependencies are. From there, you will see which one of your libraries is asking for a different version of the Android Support libraries. For whatever it is asking for, you can ask for it directly with the 25.2.0 version, or use Gradle's other conflict resolution approaches to arrange to get the same version.

    这篇关于所有com.android.support库必须使用完全相同的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆