首页 文章

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

提问于
浏览
617

更新到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

enter image description here

我的朋友:

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

30 回答

  • 6

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

    更新:

    从Android studio 3.0开始,它变得更加容易,因为它现在显示了更有用的提示,所以我们只需要遵循这个提示 .
    例如:
    ![1]](https://www.javaroad.cn/files/images/1498f029-0159-4b8d-96cc-37abd3046017.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的版本) .

    Solution:
    使用旧版本显式添加库,但使用新版本号 .
    在我的情况 com.android.support:customtabs:26.1.0 所以我需要添加:

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

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

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

    Explanation:
    你可能会被错误信息搞糊涂,因为不要使用 customtabs 所以我怎么会有冲突!!
    好吧..你没有直接使用它,但是你的一个库在内部使用旧版本的 customtabs ,所以你需要直接询问它 .

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

    请注意这一点


    旧答案:

    灵感来自CommonsWare answer

    运行Gradle依赖关系报告以查看完整的依赖关系树 .

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


    更新:

    从gradle插件版本开始:3.0 compile 已被 implementationapi 替换为this answer的区别 .

    因此使用:

    ./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插件中知道更好的方法,请告诉我 .

  • 5
    • 转到文件系统上的 project/.idea/libraries 文件夹,查看哪些库不同 .

    • 您必须在 build.gradle 文件中手动包含这些具有相同版本的库 .

    • 然后,同步您的项目 .

    例如 . :

    compile 'com.android.support:appcompat-v7:25.2.0'
    
    // Wrong library version found on 1st point
    compile 'com.android.support:customtabs:25.2.0'
    
  • 41

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

    注意关于错误的小信息窗口 it says the examples that you have to change and add .

    在这种情况下:

    找到版本25.1.1,24.0.0 . 示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0

    Your

    com.android.support:animated-vector-drawable:25.1.1

    is version 25.1.1, and your

    com.android.support:mediarouter-v7:24.0.0

    is version 24.0.0, so you have to add the mediarouter with the same version:

    com.android.support:mediarouter-v7:25.1.1
    

    对于小信息窗口所说的每个例子都这样做,在这种情况下 all the libraries that doesn't have the version 25.1.1.

    You have to sync the gradle after you fix the indicated library to see the next library and package that you have to change.

    IMPORTANT:

    如果您没有明确地使用一个或多个指定的库并且它给您错误,则意味着正在由另一个库在内部使用,无论如何都要显式编译它 .

    您还可以使用另一种方法来查看实际编译的所有库的版本差异(例如运行gradle依赖关系报告或转到库文件), the real objetive is compile all the libraries that you are using with the same version .

  • 187

    将它添加到build.gradle的最后(Module:app):

    configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.1'
            }
         }
    
       }
    }
    

    确保将'25 .3.1'替换为要用于所有依赖项的android支持库的版本,它不应低于你的complile sdk版本

    比重新同步gradle

  • 5

    更新到Android Studio 2.3后,我遇到了完全相同的问题

    将此行添加到依赖项解决了我的问题:

    compile 'com.android.support:customtabs:25.2.0'
    
  • 31

    The best way to solve the problem is implement all 'com.android.support:...' suggested by android studio

    (无论您使用哪种支持版本 - 27.1.1,28.0.0等...)

    地点光标到错误行,例如:

    实现'com.android.support:appcompat-v7:28.0.0'

    android studio会建议你'com.android.support:...'与'com.android.support:appcompat-v7:28.0.0'版本不同

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

    所以添加 com.android.support:animated-vector-drawable:28.0.0com.android.support:exifinterface:28.0.0 . 现在同步gradle文件 .

    一个接一个地尝试实现所有建议的'com.android.support:...',直到此行没有错误 implementation 'com.android.support:appcompat-v7:28.0.0'

    在我的情况下,我补充说

    implementation 'com.android.support:appcompat-v7:28.0.0'
    
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:exifinterface:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    

    所有这些依赖关系......对其他人而言可能会有所不同 .

  • 4

    A)运行 gradle dependencies./gradlew dependencies

    B)查看您的树并找出哪些依赖项为您无法控制的依赖项指定了不同的支持库版本 .

    我没有使用,你可以看到下面的大多数依赖项都被我自己的25.2.0规范覆盖,用 -> X.X.X (*) 符号表示 . 卡片视图和自定义选项卡库不是't overridden by anyone, so I need to ask for 25.2.0 for those ones myself even though I don't使用它们 .

    +--- com.facebook.android:facebook-android-sdk:4.17.0
    |    +--- com.android.support:support-v4:25.0.0 -> 25.2.0 (*)
    |    +--- com.android.support:appcompat-v7:25.0.0 -> 25.2.0 (*)
    |    +--- com.android.support:cardview-v7:25.0.0
    |    |    \--- com.android.support:support-annotations:25.0.0 -> 25.2.0
    |    +--- com.android.support:customtabs:25.0.0
    |    |    +--- com.android.support:support-compat:25.0.0 -> 25.2.0 (*)
    |    |    \--- com.android.support:support-annotations:25.0.0 -> 25.2.0
    |    \--- com.parse.bolts:bolts-android:1.4.0 (*)
    

    如果gradle已经警告过你并给你举例......

    示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0

    ...如果你为较低版本引入一些grep突出显示更容易,因为 gradle dependencies 可能非常冗长:

    ./gradlew dependencies | grep --color -E 'com.android.support:mediarouter-v7|$'
    
  • 17

    Use variables :执行以下操作将使您更容易确保对所有库使用相同的版本

    dependencies {
    
        ext {
            support_library_version = '25.2.0'
            google_play_services_version = '10.2.0'
        }
    
        //#####################################################################
        //          Support Library
        //#####################################################################
        compile "com.android.support:appcompat-v7:${support_library_version}"
        compile "com.android.support:palette-v7:${support_library_version}"
        compile "com.android.support:design:${support_library_version}"
    
        //#####################################################################
        //          Google Play Services
        //#####################################################################
        compile "com.google.android.gms:play-services-auth:${google_play_services_version}"
        compile "com.google.android.gms:play-services-ads:${google_play_services_version}"
        compile "com.google.android.gms:play-services-analytics:${google_play_services_version}"
    
        //#####################################################################
        //          Firebase
        //#####################################################################
        compile "com.google.firebase:firebase-core:${google_play_services_version}"
        compile "com.google.firebase:firebase-auth:${google_play_services_version}"
        compile "com.google.firebase:firebase-messaging:${google_play_services_version}"
    

    有关Google如何建议您处理此版本控制的更多信息,请参阅以下文章:https://developer.android.com/studio/build/index.html#top-level

  • 5

    我只想补充一点:

    compile 'com.android.support:mediarouter-v7:25.2.0'
    

    Updated 用于新的SDK版本

    compile 'com.android.support:mediarouter-v7:28.0.0-alpha3'
    
  • 4

    如果 appcompat 上出现相同的错误

    implementation 'com.android.support:appcompat-v7:27.0.1'
    

    然后添加 design 解决了它 .

    implementation 'com.android.support:appcompat-v7:27.0.1'
    implementation 'com.android.support:design:27.0.1'
    

    对我来说,补充一下

    implementation 'de.mrmaffen:vlc-android-sdk:2.0.6'
    

    包括 appcompat-v7:23.1.1 在内

    .idea / libraries

    没有 vlc ,单独 appcompat 就足够了 .

  • 5

    解决冲突的另一种方法是强制所有依赖项的正确版本,如下所示:

    dependencies {
                configurations.all {
                    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                        if (details.requested.group == 'com.android.support' && details.requested.name == 'support-v4') {
                            details.useVersion "27.0.2"
                        }
                    }
        ...
        }
    

    https://docs.gradle.org/current/userguide/customizing_dependency_resolution_behavior.html

  • 13

    正如您已经看到上面的所有答案和评论,但这个答案是为了清除新开发人员可能无法轻易获得的内容 .

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

    上面这行将毫无疑问地挽救你的生命,但是如何从上面的结果中得到确切的观点 .

    当您从上面的命令获得所有依赖关系图表或列表时,您必须搜索您在代码中获得的冲突版本号 . 请看下面的图片 .

    enter image description here

    在上面的图像中,您可以看到 23.4.0 正在创建问题,但我们无法在gradle文件中找到它 . 所以现在这个版本号(23.4.0)将节省我们 . 当我们有这个数字时,我们会在上面的命令结果的结果中找到这个数字,并直接在我们的gradle文件中直接导入该依赖项 . 请参阅下图以获得清晰的视图 .

    你可以清楚地看到 com.android.support:cardview-v7:23.4.0com.android.support:customtabs:23.4.0 正在使用创建问题的版本 . 现在只需从依赖列表中复制这些行,并在我们的gradle文件中显式使用,但使用更新的版本链接

    implementation "com.android.support:cardview-v7:26.1.0" implementation "com.android.support:customtabs:26.1.0"

  • 9

    使用support-v13而不是support-v4

    compile 'com.android.support:support-v13:25.2.0'
    
  • 13

    我的问题与你的问题类似 . 这里存在错误!

    compile 'com.android.support:appcompat-v7:25.3.0'

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

    看到这个例子包括'com.android.support:animated-vector-drawable:25.3.0'和'com.android.support:mediarouter-v7:24.0.0'

    只需在依赖项中添加这些代码,确保版本相同 .

    compile 'com.android.support:animated-vector-drawable:25.3.0'
    compile 'com.android.support:mediarouter-v7:25.3.0'
    
  • 6

    在使用编译 'com.android.support:appcompat-v7:25.3.1' 添加 compile 'com.google.android.gms:play-services:10.2.4' 后,我收到了同样的错误 .

    添加 animated-vector-drawablemediarouter libs 修复了该问题 .

    compile 'com.google.android.gms:play-services:10.2.4'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:animated-vector-drawable:25.3.1'
    compile 'com.android.support:mediarouter-v7:25.3.1'
    
  • 702

    我有这个:

    dependencies {
       implementation fileTree(dir: 'libs', include: ['*.jar'])
       implementation 'com.android.support:appcompat-v7:27.1.1'
       implementation 'com.android.support:design:27.1.1'
       implementation 'com.android.support:support-v4:27.1.1'
       implementation 'com.google.firebase:firebase-auth:12.0.1'
       implementation 'com.google.firebase:firebase-firestore:12.0.1'
       implementation 'com.google.firebase:firebase-messaging:12.0.1'
       implementation 'com.google.android.gms:play-services-auth:12.0.1'
       implementation'com.facebook.android:facebook-login:[4,5)'
       implementation 'com.twitter.sdk.android:twitter:3.1.1'
       implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
       implementation 'org.jetbrains:annotations-java5:15.0'
       implementation project(':vehiclesapi')
       testImplementation 'junit:junit:4.12'
       androidTestImplementation 'com.android.support.test:runner:1.0.1'
       androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
    

    并收到此错误:
    enter image description here

    解决方案很简单 - 主要的依赖关系都是正确的,因此叶子 - 任何第三方依赖 . 一个接一个地删除,直到找到罪魁祸首,结果是facebook!它使用Android支持库的27.0.2版本 . 我试图添加cardview版本27.1.1,但是这个解决方案仍然不够简单 .

    dependencies {
       implementation fileTree(dir: 'libs', include: ['*.jar'])
       implementation 'com.android.support:appcompat-v7:27.1.1'
       implementation 'com.android.support:design:27.1.1'
       implementation 'com.android.support:support-v4:27.1.1'
       implementation 'com.google.firebase:firebase-auth:12.0.1'
       implementation 'com.google.firebase:firebase-firestore:12.0.1'
       implementation 'com.google.firebase:firebase-messaging:12.0.1'
       implementation 'com.google.android.gms:play-services-auth:12.0.1'
       implementation('com.facebook.android:facebook-login:[4,5)'){
           // contains com.android.support:v7:27.0.2, included required com.android.support.*:27.1.1 modules
        exclude group: 'com.android.support'
       }
       implementation 'com.android.support:cardview-v7:27.1.1' // to replace facebook sdk's cardview-v7:27.0.2.
       implementation 'com.twitter.sdk.android:twitter:3.1.1'
       implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
       implementation 'org.jetbrains:annotations-java5:15.0'
       implementation project(':vehiclesapi')
       testImplementation 'junit:junit:4.12'
       androidTestImplementation 'com.android.support.test:runner:1.0.1'
       androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
    
  • 12

    升级到android studio 2.3后我用这两个来解决我的问题

    compile 'com.android.support:animated-vector-drawable:25.0.0'
    compile 'com.android.support:mediarouter-v7:25.0.0'
    
  • 8

    之前我遇到了同样的问题,我得到了解决方案 .

    我刚刚添加了具有另一个版本但具有相同版本的 support:appcompat 的库 .

    例如,对于您的错误:

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

    *解决方案是编译这些库的版本:

    compile 'com.android.support:mediarouter-v7:25.1.1'

    • 如果另一个库有相同的问题,并有另一个版本只是使用您的 support:appcompat 版本编译它

    这解决了我的问题,我希望它可以解决你的问题 .

    最好的祝愿 :)

  • 6

    您已使用版本 24.0.0 而不是 25.1.1 定义了任何其他依赖项 . 请将所有依赖项版本设置为与 25.1.1 相同 .

  • 136

    我运行了./gradlew tasks --all并检查了与目标版本(25.3.1)不同版本的依赖项 . 你会得到这样的东西:

    app:prepareComAndroidSupportAnimatedVectorDrawable2531Library - Prepare com.android.support:animated-vector-drawable:25.3.1
    app:prepareComAndroidSupportAppcompatV72531Library - Prepare com.android.support:appcompat-v7:25.3.1
    app:prepareComAndroidSupportCardviewV72531Library - Prepare com.android.support:cardview-v7:25.3.1
    app:prepareComAndroidSupportCustomtabs2531Library - Prepare com.android.support:customtabs:25.3.1
    app:prepareComAndroidSupportDesign2531Library - Prepare com.android.support:design:25.3.1
    app:prepareComAndroidSupportMediarouterV72531Library - Prepare com.android.support:mediarouter-v7:25.3.1
    app:prepareComAndroidSupportPaletteV72531Library - Prepare com.android.support:palette-v7:25.3.1
    app:prepareComAndroidSupportRecyclerviewV72531Library - Prepare com.android.support:recyclerview-v7:25.3.1
    app:prepareComAndroidSupportSupportCompat2531Library - Prepare com.android.support:support-compat:25.3.1
    app:prepareComAndroidSupportSupportCoreUi2531Library - Prepare com.android.support:support-core-ui:25.3.1
    app:prepareComAndroidSupportSupportCoreUtils2531Library - Prepare com.android.support:support-core-utils:25.3.1
    app:prepareComAndroidSupportSupportFragment2531Library - Prepare com.android.support:support-fragment:25.3.1
    app:prepareComAndroidSupportSupportMediaCompat2531Library - Prepare com.android.support:support-media-compat:25.3.1
    app:prepareComAndroidSupportSupportV42531Library - Prepare com.android.support:support-v4:25.3.1
    app:prepareComAndroidSupportSupportVectorDrawable2531Library - Prepare com.android.support:support-vector-drawable:25.3.1
    app:prepareComAndroidSupportTransition2531Library - Prepare com.android.support:transition:25.3.1
    app:prepareComAndroidVolleyVolley100Library - Prepare com.android.volley:volley:1.0.0
    app:prepareComCrashlyticsSdkAndroidAnswers1312Library - Prepare com.crashlytics.sdk.android:answers:1.3.12
    app:prepareComCrashlyticsSdkAndroidBeta124Library - Prepare com.crashlytics.sdk.android:beta:1.2.4
    app:prepareComCrashlyticsSdkAndroidCrashlytics267Library - Prepare com.crashlytics.sdk.android:crashlytics:2.6.7
    app:prepareComCrashlyticsSdkAndroidCrashlyticsCore2316Library - Prepare com.crashlytics.sdk.android:crashlytics-core:2.3.16
    app:prepareComFacebookAndroidFacebookAndroidSdk4161Library - Prepare com.facebook.android:facebook-android-sdk:4.16.1
    app:prepareComGoogleAndroidGmsPlayServicesAnalytics1026Library - Prepare com.google.android.gms:play-services-analytics:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl1026Library - Prepare com.google.android.gms:play-services-analytics-impl:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesAuth1026Library - Prepare com.google.android.gms:play-services-auth:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesAuthBase1026Library - Prepare com.google.android.gms:play-services-auth-base:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesBase1026Library - Prepare com.google.android.gms:play-services-base:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesBasement1026Library - Prepare com.google.android.gms:play-services-basement:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesCast1026Library - Prepare com.google.android.gms:play-services-cast:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesLocation1026Library - Prepare com.google.android.gms:play-services-location:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesMaps1026Library - Prepare com.google.android.gms:play-services-maps:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesTagmanagerV4Impl1026Library - Prepare com.google.android.gms:play-services-tagmanager-v4-impl:10.2.6
    app:prepareComGoogleAndroidGmsPlayServicesTasks1026Library - Prepare com.google.android.gms:play-services-tasks:10.2.6
    app:prepareComGoogleFirebaseFirebaseAnalytics1026Library - Prepare com.google.firebase:firebase-analytics:10.2.6
    app:prepareComGoogleFirebaseFirebaseAnalyticsImpl1026Library - Prepare com.google.firebase:firebase-analytics-impl:10.2.6
    app:prepareComGoogleFirebaseFirebaseAppindexing1024Library - Prepare com.google.firebase:firebase-appindexing:10.2.4
    app:prepareComGoogleFirebaseFirebaseCommon1026Library - Prepare com.google.firebase:firebase-common:10.2.6
    app:prepareComGoogleFirebaseFirebaseCore1026Library - Prepare com.google.firebase:firebase-core:10.2.6
    app:prepareComGoogleFirebaseFirebaseIid1026Library - Prepare com.google.firebase:firebase-iid:10.2.6
    app:prepareComGoogleFirebaseFirebaseMessaging1026Library - Prepare com.google.firebase:firebase-messaging:10.2.6
    app:prepareComMindorksPlaceholderview027Library - Prepare com.mindorks:placeholderview:0.2.7
    app:prepareDebugAndroidTestDependencies
    app:prepareDebugDependencies
    app:prepareDebugUnitTestDependencies
    app:prepareInfoHoang8fAndroidSegmented105Library - Prepare info.hoang8f:android-segmented:1.0.5
    app:prepareIoFabricSdkAndroidFabric1316Library - Prepare io.fabric.sdk.android:fabric:1.3.16
    app:prepareNoNordicsemiAndroidLog211Library - Prepare no.nordicsemi.android:log:2.1.1
    app:prepareNoNordicsemiAndroidSupportV18Scanner100Library - Prepare no.nordicsemi.android.support.v18:scanner:1.0.0
    

    在这种情况下,我的目标是25.3.1,并且在运行此命令时有一些针对不同版本的依赖项 . 诀窍是识别此列表中针对先前版本的依赖项,并通过在Gradle中导入最新版本的依赖项来覆盖该依赖项 .

  • 53

    我有同样的问题,但我通过添加这三行来解决这个问题

    implementation 'com.android.support:design:27.1.1'
    implementation "com.android.support:customtabs:27.1.1"
    implementation 'com.android.support:mediarouter-v7:27.1.1'
    

    现在每件事都很完美

  • 25

    这是我修复此警告的流程

    build.gradle

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

    To 查看/验证应用中所有库的 dependencies
    打开终端并运行 ./gradlew app:dependencies

    To 查看应用程序中特定库的 dependencies ,请按照以下教程进行操作: - How to exclude dependencies of a particular dependency in Gradle

    希望它有所帮助

  • 5

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

  • 9

    我只是将我的Android支持存储库更新为(版本:44.0.0);然后Android SDK工具和模拟器从sdk管理器> SDK工具到最新版本25.3.1它解决了我的问题 .

  • 6

    我必须在gradle中添加以下行以删除错误

    compile 'com.android.support:animated-vector-drawable:25.2.0'
    compile 'com.android.support:preference-v7:25.2.0'
    compile 'com.android.support:customtabs:25.2.0'
    compile 'com.android.support:cardview-v7:25.2.0'
    
  • 9

    确保所有Facebook SDK依赖项使用项目的相同支持库版本:

    dependencies {
        // Facebook SDK dependencies, excluding Bolts
        compile "com.android.support:appcompat-v7:25.4.0"
        compile "com.android.support:cardview-v7:25.4.0"
        compile "com.android.support:customtabs:25.4.0"
        compile "com.android.support:design:25.4.0"
    
        compile "com.facebook.android:facebook-android-sdk:4.23.0"
    }
    
  • 5

    突出显示错误并按“ALT ENTER”,您将看到一个选项:

    添加库依赖关系>编辑意图设置

    这将带您进入一个菜单,您将看到与support-compat不同的特定问题支持依赖项 . 在gradle(com'XXX')中创建它的依赖项并设置它的版本以匹配support-compat的版本 . 同步gradle,你就完成了 .

  • 8
    implementation 'com.android.support:appcompat-v7:26.1.0'
    

    在此行之后您必须在您的gradle中添加新行

    implementation 'com.android.support:design:26.1.0'
    
  • 82

    更新到Android Studio 2.3后,我遇到了这个问题

    在依赖项中添加这些行解决了我的问题

    compile 'com.android.support:customtabs:25.2.0'  
    compile 'com.android.support:palette-v7:25.2.0'
    
  • 51

    对我来说,错误是我导入的第三方库导致使用较旧的Google支持库模块的结果 . 我只是将它们更新到最新版本(例如检查Github),错误消失了 . 我建议您检查 build.gradle 中包含的所有非Google库是最新的 .

相关问题