更新到android studio 2.3后,我收到了这个错误消息。我知道这只是一个提示,因为应用程序运行正常,但这真的很奇怪。

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本25.1.1、24.0.0。示例包括com.android.support:animatedvector-drawable:25.1.1和com.android.com/support:mediarouter-v7:24.0.0

我的成绩:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:recyclerview-v7:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'
    compile 'com.google.android.gms:play-services-maps:10.2.0'
    compile 'com.google.android.gms:play-services:10.2.0'

    compile 'io.reactivex.rxjava2:rxjava:2.0.1'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.blankj:utilcode:1.3.6'
    compile 'com.orhanobut:logger:1.15'
    compile 'com.facebook.stetho:stetho:1.4.2'

    provided 'com.google.auto.value:auto-value:1.2'
    annotationProcessor 'com.google.auto.value:auto-value:1.2'
    annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'

    compile 'com.mikepenz:iconics-core:2.8.2@aar'
    compile('com.mikepenz:materialdrawer:5.8.1@aar') { transitive = true }
    compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
    compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
    compile 'com.github.GrenderG:Toasty:1.1.1'
    compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'
    compile 'com.github.MAXDeliveryNG:slideview:1.0.0'

    compile 'com.facebook.fresco:fresco:1.0.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'

    compile 'com.google.maps.android:android-maps-utils:0.4.4'
    compile 'com.github.jd-alexander:library:1.1.0'
}

当前回答

以下是修复此警告的流程

建筑物玻璃

android {
    compileSdkVersion ... // must same version (ex: 26)
    ...
}

dependencies {
    ...
    compile 'any com.android.support... library'  // must same version (ex: 26.0.1)
    compile 'any com.android.support... library'  // must same version (ex: 26.0.1)

    ...
    compile ('a library B which don't use 'com.android.support...' OR use SAME version of 'com.android.support'){
         // do nothing 
    }

    ...
    compile ('a library C which use DIFFERENT 'com.android.support...' (ex:27.0.1) { 
        // By default, if use don't do anything here your app will choose the higher com.android.support... for whole project (in this case it is 27.0.1)

        // If you want to use 26.0.1 use
        exclude group: 'com.android.support', module: '...' (ex module: 'appcompat-v7') 
        exclude group: 'com.android.support', module: 'another module'
        ...

        // If you want to use 27.0.1 do 
        Upgrade `compileSdkVersion` and all 'com.android.support' to 27.0.1.
        (It may be a good solution because the best practice is always use latest `compileSdkVersion`.  
        However, use 26 or 27 is base on you for example higher library may have bug)
    }
}

查看/验证应用程序中所有库的依赖关系打开终端并运行/gradlew应用程序:依存关系

要查看应用程序中特定库的依赖项,请遵循以下教程:-如何在Gradle中排除特定依赖项的依赖项

希望能有所帮助

其他回答

我的问题解决了添加以下最新的dependencyimplementation“com.google.firebase:firebaseauth:16.0.4”

打开项目的外部库,你会看到一些库仍然使用以前的版本,尽管你没有提到那些库,所以我的建议是只使用特定的库版本,这样可以解决你的问题。

在2018年更新此错误时,从项目结构中添加实现

implementation 'com.android.support:support-v13:28.0.0'

在项目模式-->外部库中,您可以在那里找到问题所在我正在使用版本28和我找到的外部库support:support-media-compat-26.0.0,这是错误。

实施后支持v13并正在运行

对于所有情况,不仅仅是这些版本或库:

注意这个小信息窗口,它显示了一些关于错误的信息,其中显示了您必须更改和添加的示例。

在这种情况下:

找到版本25.1.1、24.0.0。示例包括com.android.support:animatedvector-drawable:25.11和com.android.support:mediarouter-v7:24.0.0

Your

support:动画矢量可绘制:25.1.1

是版本25.1.1

com.android.support:mediarouter-v7:24.0.0

版本为24.0.0,因此您必须添加具有相同版本的mediarouter:

com.android.support:mediarouter-v7:25.1.1

对于小信息窗口显示的每个示例,都要这样做,在本例中,所有没有25.1.1版本的库都要这样。

修复指定的库后,必须同步放坡,以查看需要更改的下一个库和包。

重要:如果您没有显式地使用一个或多个指定的库,并且它会给您带来错误,这意味着另一个库正在内部使用它,那么无论如何都要显式地编译它。

您还可以使用另一种方法来查看您实际编译的所有库的版本的差异(例如运行grade依赖关系报告或转到库文件),真正的目的是编译您使用的所有库,使其具有相同的版本。

您可以使用以下解决方案之一解决此问题:

更新:

从Android studio 3.0开始,它变得更加容易,因为它现在显示了一个更有用的提示,所以我们只需要遵循这个提示。例如:]1

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。建立版本27.0.2、26.1.0。示例包括support:动画矢量可绘制:27.0.2和com.android.support:customtabs:26.1.0有一些库或工具和库的组合不兼容,或可能导致错误。其中一种不兼容性是使用不是最新版本(尤其是低于您的targetSdkV版本。)

解决方案:显式添加具有旧版本但具有新版本号的库。在我的例子中,com.android.support:customtabs:26.1.0,所以我需要添加:

build.gradle.kts(Kotlin构建脚本)

implementation("com.android.support:customtabs:27.0.2")

build.gradle(Groovy构建脚本)

implementation "com.android.support:customtabs:27.0.2"  

ie:从第二项中获取库,并使用第一项中的版本号实现它。

注意:不要忘记现在按sync,这样gradle可以重建依赖关系图,并查看是否有更多冲突。

说明:您可能会被错误消息所迷惑,因为不要使用customtabs,所以我怎么会有冲突!!好您没有直接使用它,但您的一个库在内部使用了旧版本的customtab,因此您需要直接请求它。

如果你想知道你的哪个库负责旧版本,并可能要求作者更新他的库,运行Gradle依赖性报告,请查看旧的答案以了解如何操作。

注意这一点


旧答案:

灵感来自CommonsWare答案:

运行Gradle依赖关系报告,查看您的完整树依赖项为。

从那里,您将看到您的哪个库要求不同版本的Android支持库。无论它要求什么,您都可以直接使用25.2.0版本或使用Gradle的其他冲突解决方法获得相同版本。


更新:

截至gradle插件版本:3.0编译已被实现或api所取代。

因此改用:

./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath

或对于windows cmd:

gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath

并搜索冲突版本。

对我来说,删除com.google.android.gms:play-services:10.2.0后,错误消失了

并且只包括com.google.android.gms:播放服务位置:10.2.0和com.google.aandroid.gms播放服务地图:10.2.0,因为它们是我使用的唯一两个播放服务。

我认为gms:play服务依赖于支持库的一些旧组件,因此我们需要自己明确地添加它们。


对于AS 3.0或更旧版本。

Run:

./gradlew -q dependencies <module-name>:dependencies --configuration implementation

例子:

./gradlew -q dependencies app:dependencies --configuration implementation

如果有人知道新的gradle插件的更好方法,请告诉我。