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

所有com.android.support库必须使用完全相同的版本规范,android,build.gradle,Android,Build.gradle,更新到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 我的格拉德尔: dependenc

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

您已经定义了使用版本
24.0.0
而不是
25.1.1
编译的任何其他依赖项。请将所有依赖项版本设置为与
25.1.1

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

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

所有com.android.support库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。建立 版本27.0.2、26.1.0。例子包括 支持:动画矢量绘图:27.0.2和 支持:customtabs:26.1.0

有一些库或工具与库的组合 不兼容,或可能导致错误。这样的不相容性之一是 使用不兼容的Android支持库版本编译 最新版本(尤其是低于您的 targetSdkVersion。)

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

implementation "com.android.support:customtabs:27.0.2"  
ie:从第二项中获取库,并使用第一项中的版本号实现它

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

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

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

注意这一点


旧答案: 灵感来自:

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

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


更新: 从gradle插件版本开始:3.0
compile
已被
implementation
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:play services location:10.2.0
com.google.android.gms:play services maps:10.2.0
,因为它们是我使用的唯一两个play服务

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


对于AS 3.0及以上版本

运行:



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

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

  • 转到文件系统上的
    project/.idea/libraries
    文件夹,查看哪些库不同
  • 您必须在
    build.gradle
    文件中手动包含这些具有相同版本的库
  • 然后,同步您的项目
  • 例如:


    在升级到Android Studio 2.3之后,我遇到了完全相同的问题

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

    compile 'com.android.support:customtabs:25.2.0'
    
    对于所有情况,而不仅仅是这些版本或库: 请注意说明错误的小信息窗口,它说明了您必须更改和添加的示例

    在这种情况下:

    找到了25.1.1、24.0.0版本。示例包括com.android.support:AnimatedVector drawable:25.1.1和 支持:mediarouter-v7:24.0.0

    你的

    支持:动画矢量绘图:25.1.1

    是25.1.1版,您的

    支持:mediarouter-v7:24.0.0

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

    com.android.support:mediarouter-v7:25.1.1
    
    对于小信息窗口显示的每个示例,都要这样做,在本例中,所有没有版本25.1.1的库。

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

    重要提示:

    com.android.support:mediarouter-v7:25.1.1
    
    如果您没有显式使用一个或多个指定的库,并且它给您带来了错误,这意味着另一个库正在内部使用该库,请显式编译它。 您还可以使用另一种方法查看实际编译的所有库的版本差异(如运行gradle dependency report或转到库文件),真正的目的是编译使用相同版本的所有库。
    compile 'com.android.support:customtabs:25.2.0'
    
    com.android.support:mediarouter-v7:25.1.1
    
    compile 'com.android.support:support-v13:25.2.0'
    
    compile 'com.android.support:mediarouter-v7:25.2.0'
    
    compile 'com.android.support:mediarouter-v7:28.0.0-alpha3'
    
    +--- 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 (*)
    
    ./gradlew dependencies | grep --color -E 'com.android.support:mediarouter-v7|$'
    
    compile 'com.android.support:animated-vector-drawable:25.0.0'
    compile 'com.android.support:mediarouter-v7:25.0.0'
    
    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}"
    
    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'
    
    compile 'com.android.support:animated-vector-drawable:25.3.0'
    compile 'com.android.support:mediarouter-v7:25.3.0'
    
    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'
    
    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
    
    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'
            }
         }
    
       }
    }
    
    implementation 'com.android.support:appcompat-v7:27.0.1'
    
    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'
    
    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)
        }
    }
    
    dependencies {
                configurations.all {
                    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                        if (details.requested.group == 'com.android.support' && details.requested.name == 'support-v4') {
                            details.useVersion "27.0.2"
                        }
                    }
        ...
        }
    
    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'
    }
    
    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'
    }
    
    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'
    
    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'
    
    ext {
        support_library_version = '28.0.0' //use the version of choice
    }
    
    implementation "com.android.support:cardview-v7:${support_library_version}"
    
    dependencies {
        ext {
            support_library_version = '28.0.0' //use the version of choice
        }
    
        implementation fileTree(include: ['*.jar'], dir: 'libs')
    
        implementation "com.android.support:animated-vector-drawable:${support_library_version}"
        implementation "com.android.support:appcompat-v7:${support_library_version}"
        implementation "com.android.support:customtabs:${support_library_version}"
        implementation "com.android.support:cardview-v7:${support_library_version}"
        implementation "com.android.support:support-compat:${support_library_version}"
        implementation "com.android.support:support-v4:${support_library_version}"
        implementation "com.android.support:support-core-utils:${support_library_version}"
        implementation "com.android.support:support-core-ui:${support_library_version}"
        implementation "com.android.support:support-fragment:${support_library_version}"
        implementation "com.android.support:support-media-compat:${support_library_version}"
        implementation "com.android.support:appcompat-v7:${support_library_version}"
        implementation "com.android.support:recyclerview-v7:${support_library_version}"
        implementation "com.android.support:design:${support_library_version}"
    
    }
    
    implementation 'com.android.support:support-v13:28.0.0'
    
    implementation 'com.android.support:exifinterface:27.1.1'
    
    implementation 'com.android.support:asynclayoutinflater:28.0.0'
    implementation 'com.android.support:exifinterface:28.0.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    
        implementation 'com.android.support:exifinterface:28.0.0'