7

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?

kerl
  • 270
  • 1
  • 3
  • 17
  • Maybe this question will help? http://stackoverflow.com/questions/20989317/multiple-dex-files-define-landroid-support-v4-accessibilityservice-accessibility – M Y May 05 '15 at 06:24

1 Answers1

10

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'
Community
  • 1
  • 1
Rob
  • 483
  • 5
  • 11
  • I have this : `implementation('org.glassfish.jersey.containers:jersey-container-servlet:2.25.1') { exclude module: 'javax.inject' } implementation 'org.glassfish.hk2.external:javax.inject:2.4.0-b06'` But it doesn't work. Says UnexpectedInput. – Shankha057 Feb 05 '18 at 19:58