I have two libs in my gradle file that require slf4j. Pusher and Gimbal. Both of these jars have slf4j in them. So even when I tell gradle to ignore them (multiDexEnabled true) I still receive a namespacing error.
Does anyone know how to fix this?
com.android.dex.DexException: Multiple dex files define Lorg/slf4j/impl/StaticLoggerBinder;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
The error I receive with (multiDexEnabled true):
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
>java.util.zip.ZipException: duplicate entry: org/slf4j/helpers/BasicMarker.class
Multidex solves a very different problem from the one you describe. Multidex fixes the issue of being limited to ~65,000 methods per dex file. You can find the documentation for multidex here.
Instead, what you want to do is exclude sl4j from one of your libraries, here's an example of what that might look like, depending on what dependencies are causing the issue:
compile ('com.example.library:library-with-sl4j:1.0') {
exclude group: 'org.sl4j', module: 'sl4j-simple'
}
You will have to identify which library is causing the issue and which sl4j module you need to exclude.
Ideally you would inform the library author(s) using older versions that they should update so that all your dependency are using the same (latest) version.