This dependency gives me two versions of the same jar. How to fix it?

I am using Gradle for my project. One of the dependencies that I pointed out in my build.gradle is compile 'org.glassfish.jersey.media:jersey-media-moxy:2.0'

This works fine on a regular Java application, however, when I try to create it on Android, I get:

When looking at which libraries are referenced, it is clear that both javax.inject-2.3.0-b05.jar and javax.inject-1.jar , which I found, are added with the dependency above. I assume that this โ€œduplicateโ€ jar causes a build error.

How do I get around this? Why does this addiction include two identical banks? Is there a way to make an Android version with these two banks or remove one of these banks?

+6
source share
2 answers

It looks like you have akin dependency tree

 project |--- org.glassfish.jersey.media:jersey-media-moxy:2.0 | \--- *:javax.inject:1 \--- *:javax.inject:2.3.0-b05 

Where * is a group that I suspect may be different from two.

Try to understand how your dependencies are captured using the dependency task

 gradle dependency 

If you need to exclude the dependency, enter it in the tag, similar to the example below

 compile('org.hibernate:hibernate:3.1') { //excluding a particular transitive dependency: exclude module: 'cglib' //by artifact name exclude group: 'org.jmock' //by group exclude group: 'org.unwanted', module: 'iAmBuggy' //by both name and group } 
+2
source

Typically, a gradle will only include 1 drum per addiction. If another version is found for the same dependencies, a newer version will be used.

However, in your case, these 2 jars are dependencies with different group names:

 'javax.inject:javax.inject:1' 'org.glassfish.hk2.external:javax.inject:2.3.0-b05' 

This is why gradle included both, as they are treated as different dependencies.

'javax.inject: javax.inject: 1' is very old, I think you should exclude it, as Niels Beh Nielsen said.

To find out where this dependency came from, you can use the command:

 gradle -q dependencyInsight --dependency inject 
+1
source

Source: https://habr.com/ru/post/971836/


All Articles