Android gradle modules with the same name

I am working on an Android project that uses the following dependency:

<dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.17</version> </dependency> 

However, this dependency has 2 javax / inject module definitions, as shown here in the gradle dependency tree:

  +--- org.glassfish.jersey.core:jersey-client:2.17 | +--- org.glassfish.jersey.core:jersey-common:2.17 | | +--- org.glassfish.hk2:hk2-api:2.4.0-b10 | | | +--- javax.inject:javax.inject:1 | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b10 

When I try to launch an Android application, I get an error message:

 com.android.dex.DexException: Multiple dex files define L/javax/inject/Inject 

I tried to exclude any of these modules, but this does not work, because the dependency uses both of them to call methods.

Are there any other solutions to resolve this conflict?

+7
java android gradle
source share
1 answer

I am using gradle and had the same problem and solved it according to this answer

 compile ('org.glassfish.jersey.containers:jersey-container-servlet:2.14'){ exclude module: 'javax.inject' } compile 'org.glassfish.hk2.external:javax.inject:2.4.0-b06' 
+10
source share

All Articles