首页 > 解决方案 > Android Studio,不匹配支持库版本错误,但不知道它在哪里指定

问题描述

在 Android Studio 中进行项目,并收到此错误:

com.android.support 库必须使用完全相同的版本规范。

找到版本 com.android.support:support-compat:25.2.0 和 com.android.support:app-compat-v7:22.2.1

但是问题是,我的 build.gradle 文件中没有对 com.android.support:support-compat:25.2.0 的引用

那么,我在哪里可以找到这种依赖关系的来源?这是我的依赖项:

模块构建

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':lvl')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-maps:11.6.0'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'org.jsoup:jsoup:1.10.3'
compile 'com.google.apis:google-api-services-oauth2:v1-rev143-1.24.1'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.1.0'
compile 'com.android.support:design:22.2.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:support-v4:22.2.1'
}

项目建设:

 dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

我很困惑。这个 25.2.0 支持依赖来自哪里?我该如何摆脱它?

标签: androidandroid-studiogradleandroid-support-librarygradle-dependencies

解决方案


似乎任何第 3 方都在内部使用此支持库依赖项。您可以使用以下 gradle 任务查看依赖关系树:

gradle app:dependencies  

它将打印所有直接依赖项以及您包含的任何 1st/2nd/3rd 方库声明的依赖项。

然后你可以做这样的事情来从你的树中排除这个依赖,例如,如果 play-services 是罪魁祸首,那么你可以做这样的事情:

compile('com.google.android.gms:play-services-base:6.5.1'){
            exclude module: 'support-v4'
}

推荐阅读