Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 definitions of the module javax/inject 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 attempting to run the Android application I get the error:

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

I have tried excluding either of these modules but that does not work because the dependency relies on both of them to make method calls.

Are there any other solutions to resolve this conflict?

like image 388
kerl Avatar asked May 05 '15 02:05

kerl


1 Answers

I am using gradle and had the same issue 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'
like image 69
Rob Avatar answered Sep 22 '22 00:09

Rob