简体   繁体   中英

How to resolve conflicts with multiple versions of the same dependencies

I've marked my dependencies to be 24.2.1 in app/build gradle file, but when i run " gradlw app:dependencies" it shows 25.1.0 as resolved.not sure how this happening as i haven't add any dependency with 25.1.0 ?is there any way i can find which library pulling the latest

  gradlw app:dependencies
    -- com.android.support:appcompat-v7:24.2.1 -> 25.1.0
       +--- com.android.support:support-annotations:25.1.0
       +--- com.android.support:support-v4:25.1.0

In Android Studio 在此处输入图片说明

When this happen it's because another library you are using is pulling in other versions of the same dependencies.

You need to figure out your dependency tree with the command

./gradlew app:dependencies

to execute in the Android Studio terminal.

Then you need to scroll up the terminal window until you find the dependencies tree, check for some nested dependency coming from thirdy party libraries like in the example image below.

在此处输入图片说明

When you have found a version conflict between the third party dependency and the same dependency you declared in your buid.gradle you can exclude the pulled library and force the library to use your version:

For your problem with the support-library, you could proceed in this way:

compile ("com.example.libwithconfictdependency:library:1.0.0") {
    //this to exclude specific modules
    exclude group: 'com.android.support', module: 'support-v4'
    //or this to exclude every modules of the same package
    exclude group: 'com.android.support'
}

The problems in this case are:

  1. The library could not work because the dependency you overrided manually are not compatible with the library code
  2. You need to provide all the necessary dependencies in your build.gradle

That's up to you decide how to proceed about this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM