All com.android.support libraries must use the exact same version specification

前端 未结 30 2147
忘掉有多难
忘掉有多难 2020-11-21 05:10

After updating to android studio 2.3 I got this error message. I know it\'s just a hint as the app run normally but it\'s really strange.

All com.andr

相关标签:
30条回答
  • 2020-11-21 05:50

    I used these two to solve my problem after upgrading to android studio 2.3

    compile 'com.android.support:animated-vector-drawable:25.0.0'
    compile 'com.android.support:mediarouter-v7:25.0.0'
    
    0 讨论(0)
  • 2020-11-21 05:54

    I had the exact same problem after updating to Android Studio 2.3

    Adding this line to dependencies solved my problem:

    compile 'com.android.support:customtabs:25.2.0'
    
    0 讨论(0)
  • 2020-11-21 05:54

    Use variables: Doing something like the following will make it easier for you to ensure that you use the same version with all libraries

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

    More information on how Google suggests that you handle this versioning can be found in this article: https://developer.android.com/studio/build/index.html#top-level

    0 讨论(0)
  • 2020-11-21 05:54

    Another way to solve conflicts is just to force the correct version for all dependencies like this:

    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

    0 讨论(0)
  • 2020-11-21 05:54

    add these in app level dependencies

    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'
    
    0 讨论(0)
  • 2020-11-21 05:54

    Here is my flow to fix this warning

    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 view/verify the dependencies of all library in your app
    Open terminal and run ./gradlew app:dependencies

    To view the dependencies of a specific library in your app follow tutorial here :- How to exclude dependencies of a particular dependency in Gradle

    Hope it help

    0 讨论(0)
提交回复
热议问题