0

I have a library i share on jcenter for maven and gradle users to add to their dependencies. This library uses some common stuff like gson, guava, etc. It is part of a large multi-module project but i only deploy the one child module to the repositories. The complete parent pom.xml is here:

https://github.com/bsautner/com.nimbits/blob/master/pom.xml

The child pom that results in the library's pom is here:

https://github.com/bsautner/com.nimbits/blob/master/nimbits_io/pom.xml

The child pom has dependencies like this:

       <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0</version>
      </dependency>

Pretty standard. When I import my library into an android project (gradle in this case) I need to include a transitive=false like this:

  compile ('com.nimbits:nimbits_io:3.9.47') {

        transitive = false

    }

If I don't do this, android builds fail with many errors like this one:

Error:Gradle: Execution failed for task ':app:packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: org/slf4j/impl/StaticLoggerBinder.class

My understanding is that my jar has duplicate dependencies already in the android project.

I don't get what i'm doing wrong, and why i need to use that flag. If i set these dependencies as "provided" I'd need my users to add my libraries to their dependencies. How do I share a library with dependencies without causing duplicate errors with the user. No other libraries require this flag, so i must be doing something wrong

bsautner
  • 4,479
  • 1
  • 36
  • 50
  • can this be a duplicate? http://stackoverflow.com/questions/26966843/java-util-zip-zipexception-duplicate-entry-during-packagealldebugclassesformult – Daniele Segato Mar 04 '16 at 18:11
  • some of your dependencies might be including that slf4j entry, you might need to exclude sl4j from the dependencies that are using them and set your own? check your dependency tree on maven for more insight. – rastadrian Mar 04 '16 at 18:13
  • @DanieleSegato i think that question is more from a user's perspective while my question is what do i need to do to keep users from having that problem - i'm doing some digging with mvn dependency:tree - maybe i just have some dups in the build – bsautner Mar 04 '16 at 18:28
  • @bsautner are you saying that your dependency will ALWAYS be available to the user of your library even if you do not declare it in your library? Sounds like a runtime (over compile) dependency to me. – Daniele Segato Mar 04 '16 at 18:32
  • my parent pom.xml had a dependency for the maven-release-plugin i didn't need and it contained a lot of libraries like slf4j using mvn dependency:tree listed all of the libraries i was using an and helped identify that. Once it was removed i was able to add my library to an android project without transitive = false - good to go, thanks for the help fellas – bsautner Mar 04 '16 at 18:56

0 Answers0