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

前端 未结 30 2079
忘掉有多难
忘掉有多难 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: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

提交回复
热议问题