When creating my project, the following error occurs:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/slf4j/impl/StaticLoggerBinder;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
As I understand it, this is because I have several libraries that depend on slf4j. Dependencies in the build.gradle file:
dependencies {
compile project(':libraries:some-sdk')
compile files('libs/some-library.jar')
compile 'com.some-module:some-artifact:X.X.X'
compile 'com.github.tony19:logback-android-classic:1.1.1-3'
}
I know that the logback-android-classic dependency is a problem because it depends on slf4j, and if I comment that my project build is beautiful. According to other sources, I found that this is usually solved by eliminating the transitive dependency as follows:
compile('com.github.tony19:logback-android-classic:1.1.1-3') {
exclude group: 'org.slf4j'
However, even after cleaning and restoring, I still get the error.
UPDATE: Running dependencyInsight looking for slf4j, as dmahapatro suggested, did not produce any results:
$ gradle -q dependencyInsight --dependency slf4j --configuration compile
No dependencies matching given input were found in configuration ':main:compile'
My complete dependency tree:
+
+
+
+
+
+
+
+
+
+
\
+
| \
| +
| +
| | +
| | +
| | \
| +
| +
| \
\
Update 2:
( , - ). , . , org.slf4j, - . - slf4j logback-android-classic. , slf4j logback-android-classic, ,
compile('com.github.tony19:logback-android-classic:1.1.1-3') {
exclude group: 'org.slf4j'
}
, slf4j logback-android-classic?
:
, , , . , , .