Question

Hi i appear to have a duplicated dependency on a project i am trying to build.

the error is below:

[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Landroid/support/v4/content/LocalBroadcastManager$BroadcastRecord;
[INFO]  at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
[INFO]  at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
[INFO]  at com.android.dx.command.dexer.Main.processClass(Main.java:685)
[INFO]  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
[INFO]  at com.android.dx.command.dexer.Main.access$600(Main.java:78)
[INFO]  at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[INFO]  at com.android.dx.command.dexer.Main.processOne(Main.java:596)
[INFO]  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
[INFO]  at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
[INFO]  at com.android.dx.command.dexer.Main.run(Main.java:230)
[INFO]  at com.android.dx.command.dexer.Main.main(Main.java:199)
[INFO]  at com.android.dx.command.Main.main(Main.java:103)
[INFO] 1 error; aborting

i am working on two projects. one acts as a api/sdk and the other a client app that uses this api/sdk.

the api/sdk uses the support v4 android dependency library for one class/interface called LocalbroadcastManager and the client app uses the same library but different classes.

The issue is that when you add the sdk/api as a dependency for the client app, it also includes the v4 support library dependency. However, the Supported v4 lib dependency only shows the LocalBroadCastManager and so you have to create and add the dependency on the client itself for the whole v4 support lib.

Now i know what the issue is, i am trying to figure out how i can just use the whole v4 support library from the sdk/api project and basically how to expose the whole v4 support lib from that sdk/api project?

this should fix the error i am getting as only one LocalBroadcastManager plus any other v4 support lib class will only be added once in the client project.

pom snippet from the client app

<dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>${android.support.v4.version}</version>
        </dependency>

Pom snippet from the sdk/api project

 <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>${android.support.v4.version}</version>
        </dependency>

More or less identical so how do i use only one?

Thanks

Was it helpful?

Solution

Add an exclusion to one of the dependencies that uses the support lib:

<dependency>
  <!-- one of the dependencies containing the support lib -->
  <exclusions>
    <exclusion>
      <groupId>com.google.android</groupId>
      <artifactId>support-v4</artifactId>
    </exclusion>
  </exclusions>
</dependency>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top