Jackson / JSON:调用新的ObjectMapper()时ExceptionInInitializerError

时间:2012-09-04 09:28:33

标签: android broadcastreceiver jackson

我在我的Android应用中使用Jackson。我有一个BroadcastReceiver用于保存有关整个调用的信息的传入调用,然后我将它保存到JSON数组中的JSON对象。

然后,我得到下面的例外,它指向我呼叫ObjectMapper mapper = new ObjectMapper()的行。因为我没有写这些课,所以我不知道该怎么办。帮助

09-04 09:08:58.220: E/AndroidRuntime(4445): FATAL EXCEPTION: main
09-04 09:08:58.220: E/AndroidRuntime(4445): java.lang.ExceptionInInitializerError
09-04 09:08:58.220: E/AndroidRuntime(4445):     at com.ourcompany.appname.IncomingCallDetector.saveLog(IncomingCallDetector.java:80)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at com.ourcompany.appname.IncomingCallDetector.onReceive(IncomingCallDetector.java:70)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2816)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at android.app.ActivityThread.access$3200(ActivityThread.java:126)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2088)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at android.os.Looper.loop(Looper.java:123)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at android.app.ActivityThread.main(ActivityThread.java:4633)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at java.lang.reflect.Method.invokeNative(Native Method)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at java.lang.reflect.Method.invoke(Method.java:521)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-04 09:08:58.220: E/AndroidRuntime(4445):     at dalvik.system.NativeStart.main(Native Method)
09-04 09:08:58.220: E/AndroidRuntime(4445): Caused by: java.lang.ExceptionInInitializerError
09-04 09:08:58.220: E/AndroidRuntime(4445):     at com.fasterxml.jackson.databind.ObjectMapper.<clinit>(ObjectMapper.java:197)
09-04 09:08:58.220: E/AndroidRuntime(4445):     ... 13 more
09-04 09:08:58.220: E/AndroidRuntime(4445): Caused by: java.lang.NoClassDefFoundError: com.fasterxml.jackson.annotation.JsonAutoDetect
09-04 09:08:58.220: E/AndroidRuntime(4445):     at com.fasterxml.jackson.databind.introspect.VisibilityChecker$Std.<clinit>(VisibilityChecker.java:169)
09-04 09:08:58.220: E/AndroidRuntime(4445):     ... 14 more

我的广播接收器在这里:http://pastie.org/4661134

1 个答案:

答案 0 :(得分:5)

似乎发生的事情是JsonAutoDetect未添加到您的项目中。确保它包含在apk中(如果你正在使用eclipse,请参阅eclipse中的classpath部分)