Android和slf4j:“java.lang.NoClassDefFoundError:org.slf4j.LoggerFactory”

时间:2012-04-14 10:23:53

标签: android eclipse slf4j

两天前,当我在eclipse中的android项目仍然有效时,我在我的SDK中添加了“android SDK 4.0.3”(除了android SDK 2.1)。

从那一刻开始,我遇到了 slf4j-android 库的问题;这是例外:

Uncaught handler: thread main exiting due to uncaught exception
  java.lang.ExceptionInInitializerError
  at java.lang.Class.newInstanceImpl(Native Method)
  at java.lang.Class.newInstance(Class.java:1479)
  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4363)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
  at it.cefriel.swa.urbanopoly.client.game.UrbanopolyActivity.<clinit>(UrbanopolyActivity.java:11)

我使用的JAR是 slf4j-android-1.5.8.jar 。构建路径似乎正确设置。我还尝试使用slf4j创建另一个项目,我得到了同样的错误..

任何想法?

提前致谢

1 个答案:

答案 0 :(得分:0)

尝试添加slf4j-api-1.5.8.jar或最新版本以及当前的slf4j-android-1.5.8.jar