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

新手上路,请多包涵

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

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 25.1.1、24.0.0。示例包括 com.android.support:animated-vector-drawable:25.1.1 和 com.android.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'
}

原文由 humazed 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 662
2 个回答

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

更新:

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

例如:![1]](https://i.stack.imgur.com/BObtK.png)

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

有一些库或工具和库的组合不兼容,或者可能导致错误。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译。

解决方案:

使用旧版本显式添加库,但使用新版本号。

在我的情况下 com.android.support:customtabs:26.1.0 所以我需要添加:

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

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

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

解释:

您可能会对错误消息感到困惑,因为不要使用 customtabs 所以我有什么冲突!

好吧..您没有直接使用它,但是您的一个库在内部使用了旧版本的 customtabs ,因此您需要直接询问。

如果您想知道您的哪些库负责旧版本,并且可能要求作者更新他的库,请运行 Gradle 依赖关系报告,请参阅旧答案以了解如何操作。

注意这个


老答案:

灵感来自 CommonsWare 答案

运行 Gradle 依赖关系报告以查看完整的依赖关系树是什么。

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


更新:

从 gradle 插件版本开始: 3.0 compile 已被替换为 implementationapi 请参阅 此答案 以了解差异。

因此改用:

 ./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:play-services-location:10.2.0com.google.android.gms:play-services-maps:10.2.0 因为它们是我使用的仅有的两个播放服务。

我认为 gms:play-services 依赖于支持库的一些旧组件,所以我们需要自己显式添加它们。


对于 AS 3.0 更早的版本。

跑:

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

例子:

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


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

原文由 humazed 发布,翻译遵循 CC BY-SA 4.0 许可协议

我的项目中有这些依赖项:

 implementation 'com.android.support.constraint:constraint-layout:1.1.3'

implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'

implementation 'com.google.android.gms:play-services-maps:16.1.0'

implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-storage:17.0.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'

implementation 'com.firebaseui:firebase-ui-storage:0.6.0'

到目前为止,似乎没有任何问题,但我收到了这条消息:

找到版本 28.0.0、23.4.0。示例包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:palette-v7:23.4。

然后我做了:

 $ ./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath >> dep.txt

在文件中,我搜索了 _调色板_,发现它是由 firebase storage 使用的:

 \--- com.firebaseui:firebase-ui-storage:0.6.0
     +--- com.android.support:appcompat-v7:23.4.0 -> 28.0.0 (*)
     +--- com.android.support:palette-v7:23.4.0

添加后:

 implementation 'com.android.support:palette-v7:28.0.0'

似乎解决了,没有更多的错误。

//干杯

原文由 stargazer_94 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题