How to fix: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
How to fix: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
我有一个包含图书馆项目的项目。
我的主要项目具有以下依赖项:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':foundationclasses')
compile 'com.android.support:multidex:'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
//NEUROTECHNOLOGY
compile files('libs/neurotec-media-android.jar')
compile files('libs/neurotec-media-processing-android.jar')
compile files('libs/neurotec-licensing-gui-android.jar')
compile files('libs/neurotec-licensing-android.jar')
compile files('libs/neurotec-gui-android.jar')
compile files('libs/neurotec-devices-android.jar')
compile files('libs/neurotec-core-android.jar')
compile files('libs/neurotec-cluster-android.jar')
compile files('libs/neurotec-biometrics-gui-android.jar')
compile files('libs/neurotec-biometrics-client-android.jar')
compile files('libs/neurotec-biometrics-android.jar')
compile files('libs/jna.jar')
compile files('libs/acra.jar')
//CREDENCE
compile files('libs/CredenceDeviceLib.jar')
//OTHER
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.6'
compile 'joda-time:joda-time:2.9.3'
compile 'com.wang.avi:library:1.0.2'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
}
我的库项目的依赖项:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.guava:guava:18.0'
compile 'com.github.tony19:logback-android-classic:1.1.1-4'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
}
gradlew app:dependencies 给出以下结果:
compile - Classpath for compiling the main sources.
+--- project :foundationclasses
| +--- com.google.guava:guava:18.0
| +--- com.github.tony19:logback-android-classic:1.1.1-4
| | +--- com.github.tony19:apktool-lib:1.4.4-3
| | | \--- com.google.android:android:2.1_r1
| | | +--- commons-logging:commons-logging:1.1.1
| | | +--- org.apache.httpcomponents:httpclient:4.0.1
| | | | +--- org.apache.httpcomponents:httpcore:4.0.1
| | | | +--- commons-logging:commons-logging:1.1.1
| | | | \--- commons-codec:commons-codec:1.3
| | | +--- org.khronos:opengl-api:gl1.1-android-2.1_r1
| | | +--- xerces:xmlParserAPIs:2.6.2
| | | \--- xpp3:xpp3:1.1.4c
| | \--- com.github.tony19:logback-android-core:1.1.1-4
| \--- org.slf4j:slf4j-api:1.7.12
+--- com.android.support:multidex: FAILED
+--- com.android.support:appcompat-v7:23.3.0
| +--- com.android.support:support-vector-drawable:23.3.0
| | \--- com.android.support:support-v4:23.3.0
| | \--- com.android.support:support-annotations:23.3.0
| +--- com.android.support:animated-vector-drawable:23.3.0
| | \--- com.android.support:support-vector-drawable:23.3.0 (*)
| \--- com.android.support:support-v4:23.3.0 (*)
+--- cn.pedant.sweetalert:library:1.3
| \--- com.pnikosis:materialish-progress:1.0
| \--- com.android.support:appcompat-v7:21.0.0 -> 23.3.0 (*)
+--- com.github.fengdai:alertdialogpro-theme-material:0.2.6
| +--- com.nineoldandroids:library:2.4.0
| \--- com.github.fengdai:alertdialogpro-core:0.2.6
| \--- com.android.support:appcompat-v7:23.1.1 -> 23.3.0 (*)
+--- joda-time:joda-time:2.9.3
+--- com.wang.avi:library:1.0.2
| +--- com.android.support:appcompat-v7:22.2.0 -> 23.3.0 (*)
| \--- com.nineoldandroids:library:2.4.0
\--- org.slf4j:slf4j-api:1.7.12
错误日志:
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at nl.hsb.abis.fsm.ActivityController.<clinit>(ActivityController.java:33)
at nl.hsb.finalapplication.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.access0(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5289)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
我已经尝试了所有方法,但我无法摆脱这个错误,任何建议将不胜感激!
您包含了 slf4j API 但没有实现。根据您要使用的记录器,有几种不同的实现模块。
例如,您可以为简单记录器添加依赖项:
dependencies {
...
runtime group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.12'
...
}
{org.slf4j.LoggerFactory} class 附带 slf4j-api.jar。由于某些神秘原因,slf4j-api.jar 在运行时不是您的应用程序的一部分。
我有一个包含图书馆项目的项目。 我的主要项目具有以下依赖项:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':foundationclasses')
compile 'com.android.support:multidex:'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
//NEUROTECHNOLOGY
compile files('libs/neurotec-media-android.jar')
compile files('libs/neurotec-media-processing-android.jar')
compile files('libs/neurotec-licensing-gui-android.jar')
compile files('libs/neurotec-licensing-android.jar')
compile files('libs/neurotec-gui-android.jar')
compile files('libs/neurotec-devices-android.jar')
compile files('libs/neurotec-core-android.jar')
compile files('libs/neurotec-cluster-android.jar')
compile files('libs/neurotec-biometrics-gui-android.jar')
compile files('libs/neurotec-biometrics-client-android.jar')
compile files('libs/neurotec-biometrics-android.jar')
compile files('libs/jna.jar')
compile files('libs/acra.jar')
//CREDENCE
compile files('libs/CredenceDeviceLib.jar')
//OTHER
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.6'
compile 'joda-time:joda-time:2.9.3'
compile 'com.wang.avi:library:1.0.2'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
}
我的库项目的依赖项:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.guava:guava:18.0'
compile 'com.github.tony19:logback-android-classic:1.1.1-4'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
}
gradlew app:dependencies 给出以下结果:
compile - Classpath for compiling the main sources.
+--- project :foundationclasses
| +--- com.google.guava:guava:18.0
| +--- com.github.tony19:logback-android-classic:1.1.1-4
| | +--- com.github.tony19:apktool-lib:1.4.4-3
| | | \--- com.google.android:android:2.1_r1
| | | +--- commons-logging:commons-logging:1.1.1
| | | +--- org.apache.httpcomponents:httpclient:4.0.1
| | | | +--- org.apache.httpcomponents:httpcore:4.0.1
| | | | +--- commons-logging:commons-logging:1.1.1
| | | | \--- commons-codec:commons-codec:1.3
| | | +--- org.khronos:opengl-api:gl1.1-android-2.1_r1
| | | +--- xerces:xmlParserAPIs:2.6.2
| | | \--- xpp3:xpp3:1.1.4c
| | \--- com.github.tony19:logback-android-core:1.1.1-4
| \--- org.slf4j:slf4j-api:1.7.12
+--- com.android.support:multidex: FAILED
+--- com.android.support:appcompat-v7:23.3.0
| +--- com.android.support:support-vector-drawable:23.3.0
| | \--- com.android.support:support-v4:23.3.0
| | \--- com.android.support:support-annotations:23.3.0
| +--- com.android.support:animated-vector-drawable:23.3.0
| | \--- com.android.support:support-vector-drawable:23.3.0 (*)
| \--- com.android.support:support-v4:23.3.0 (*)
+--- cn.pedant.sweetalert:library:1.3
| \--- com.pnikosis:materialish-progress:1.0
| \--- com.android.support:appcompat-v7:21.0.0 -> 23.3.0 (*)
+--- com.github.fengdai:alertdialogpro-theme-material:0.2.6
| +--- com.nineoldandroids:library:2.4.0
| \--- com.github.fengdai:alertdialogpro-core:0.2.6
| \--- com.android.support:appcompat-v7:23.1.1 -> 23.3.0 (*)
+--- joda-time:joda-time:2.9.3
+--- com.wang.avi:library:1.0.2
| +--- com.android.support:appcompat-v7:22.2.0 -> 23.3.0 (*)
| \--- com.nineoldandroids:library:2.4.0
\--- org.slf4j:slf4j-api:1.7.12
错误日志:
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at nl.hsb.abis.fsm.ActivityController.<clinit>(ActivityController.java:33)
at nl.hsb.finalapplication.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.access0(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5289)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
我已经尝试了所有方法,但我无法摆脱这个错误,任何建议将不胜感激!
您包含了 slf4j API 但没有实现。根据您要使用的记录器,有几种不同的实现模块。
例如,您可以为简单记录器添加依赖项:
dependencies {
...
runtime group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.12'
...
}
{org.slf4j.LoggerFactory} class 附带 slf4j-api.jar。由于某些神秘原因,slf4j-api.jar 在运行时不是您的应用程序的一部分。