我在Eclipse项目的“Referenced libraries”部分导入了facebooksdk.jar。当创建Facebook实例时,我遇到了以下异常。 Facebook SDK是3.15.0。
任何指出解决以下问题的方法都表示赞赏。
Thread [<1> main] (Suspended (exception NoClassDefFoundError))
<VM does not provide monitor information>
WebDialog.onCreate(Bundle) line: 208
WebDialog(Dialog).dispatchOnCreate(Bundle) line: 361
WebDialog(Dialog).show() line: 262
AuthorizationClient$WebViewAuthHandler.tryAuthorize(AuthorizationClient$AuthorizationRequest) line: 628
AuthorizationClient.tryCurrentHandler() line: 264
AuthorizationClient.tryNextHandler() line: 230
AuthorizationClient.authorize(AuthorizationClient$AuthorizationRequest) line: 154
AuthorizationClient.startOrContinueAuth(AuthorizationClient$AuthorizationRequest) line: 135
Session.tryLegacyAuth(Session$AuthorizationRequest) line: 1450
Session.authorize(Session$AuthorizationRequest) line: 1165
Session.open(Session$OpenRequest, SessionAuthorizationType) line: 1234
Session.openForPublish(Session$OpenRequest) line: 503
Facebook.openSession(Session, Session$OpenRequest, boolean) line: 319
Facebook.authorize(Activity, String[], int, SessionLoginBehavior, Facebook$DialogListener) line: 313
Facebook.authorize(Activity, String[], Facebook$DialogListener) line: 149
FacebookConnector.login() line: 49
AndroidFacebook.postMessage() line: 116
AndroidFacebook.onCreate(Bundle) line: 57
AndroidFacebook(Activity).performCreate(Bundle) line: 5231
Instrumentation.callActivityOnCreate(Activity, Bundle) line: 1087
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2159
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2245
ActivityThread.access$800(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 135
ActivityThread$H.handleMessage(Message) line: 1196
ActivityThread$H(Handler).dispatchMessage(Message) line: 102
Looper.loop() line: 136
ActivityThread.main(String[]) line: 5017
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 515
ZygoteInit$MethodAndArgsCaller.run() line: 779
ZygoteInit.main(String[]) line: 595
NativeStart.main(String[]) line: not available [native method]
继续使用上述断点运行后,会发现另一个异常“InvocationTargetException”,原因是“NoClassDefFoundError”。
Eclipse Variables窗口中的原因/目标如下所示 java.lang.NoClassDefFoundError:com.facebook.android.R $ string生成facebook SDK jar时在R.txt中的条目未找到。
android.content.res.Resources $ NotFoundException:字符串资源ID#0x7f070011,其中ID解析为以下
int string com_facebook_loading 0x7f070011
还包括以下jar文件 - android-support-v4,bolts.jar,android-support-v7-appcompat,appcompat_v7