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

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

问题描述

当我今天将我的 android studio 从版本 2.2.3 更新到 2.3 时,我突然在我的 build.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):

所有 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

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

我已经浏览了我的整个项目,但找不到 24.0.0 版本的任何用法(我已经使用 ctrl + shift + F 在整个项目中进行搜索)

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)

这是我的 build.gradle:

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'
}

推荐答案

我已经浏览了我的整个项目,但找不到 24.0.0 版本的任何用法

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.

首先,修复您的 build.gradle 文件中的其他问题,因为它们也可能会解决这个问题:

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.

不要使用play-services.对所需的 Play Services SDK 的特定部分使用特定的依赖项.play-services 引入了所有的 Play 服务,使您的应用比它需要的要大得多,并大大减慢了您的构建时间.

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.

com.mcxiaoke.volley 替换为官方的 Volley 神器 (com.android.volley:volley:1.0.0)

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

如果这些都不能解决问题,您可以运行 Gradle 依赖关系报告来查看您的完整依赖关系树是什么.从那里,您将看到您的哪个库要求不同版本的 Android 支持库.无论它要求什么,您都可以直接使用 25.2.0 版本要求它,或者使用 Gradle 的其他冲突解决方法来安排获得相同的版本.

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天全站免登陆