使用Parse.com登录Facebook时出现NoClassDefFoundError

时间:2013-03-03 15:04:43

标签: android facebook parse-platform

我目前正在使用parse.com作为我的Android应用的后端解决方案。我正在尝试使用Facebook对用户进行身份验证,我目前正在遇到以下错误。我试图将JARS(Parse和Facebook)添加到我的项目中。我也多次清理过我的项目,但我仍然得到以下错误:

错误日志:

03-03 15:01:18.273: E/dalvikvm(7423): Could not find class 'com.facebook.SharedPreferencesTokenCachingStrategy', referenced from method com.parse.auth.FacebookAuthenticationProvider.authenticate
03-03 15:01:18.273: W/dalvikvm(7423): VFY: unable to resolve new-instance 1011 (Lcom/facebook/SharedPreferencesTokenCachingStrategy;) in Lcom/parse/auth/FacebookAuthenticationProvider;
03-03 15:01:18.277: D/dalvikvm(7423): VFY: replacing opcode 0x22 at 0x0033
03-03 15:01:18.277: E/dalvikvm(7423): Could not find class 'com.facebook.SharedPreferencesTokenCachingStrategy', referenced from method com.parse.auth.FacebookAuthenticationProvider.restoreAuthentication
03-03 15:01:18.277: W/dalvikvm(7423): VFY: unable to resolve new-instance 1011 (Lcom/facebook/SharedPreferencesTokenCachingStrategy;) in Lcom/parse/auth/FacebookAuthenticationProvider;
03-03 15:01:18.277: D/dalvikvm(7423): VFY: replacing opcode 0x22 at 0x003b
03-03 15:01:18.277: D/dalvikvm(7423): DexOpt: unable to opt direct call 0x21d7 at 0x35 in Lcom/parse/auth/FacebookAuthenticationProvider;.authenticate
03-03 15:01:18.281: D/dalvikvm(7423): DexOpt: unable to opt direct call 0x21d7 at 0x3f in Lcom/parse/auth/FacebookAuthenticationProvider;.restoreAuthentication
03-03 15:01:18.324: D/AndroidRuntime(7423): Shutting down VM
03-03 15:01:18.328: W/dalvikvm(7423): threadid=1: thread exiting with uncaught exception (group=0x40dc6300)
03-03 15:01:18.371: E/AndroidRuntime(7423): FATAL EXCEPTION: main
03-03 15:01:18.371: E/AndroidRuntime(7423): java.lang.NoClassDefFoundError: com.facebook.SharedPreferencesTokenCachingStrategy
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.parse.auth.FacebookAuthenticationProvider.authenticate(FacebookAuthenticationProvider.java:114)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.parse.ParseUser.authenticateAsync(ParseUser.java:1096)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.parse.ParseUser.logInWithAsync(ParseUser.java:1113)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.parse.ParseUser.logInWithAsync(ParseUser.java:938)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.parse.ParseFacebookUtils.logIn(ParseFacebookUtils.java:338)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.parse.ParseFacebookUtils.logIn(ParseFacebookUtils.java:363)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.example.chartviewer.FbLoginActivity.onCreate(FbLoginActivity.java:44)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.app.Activity.performCreate(Activity.java:5008)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.os.Looper.loop(Looper.java:137)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at android.app.ActivityThread.main(ActivityThread.java:4745)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at java.lang.reflect.Method.invokeNative(Native Method)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at java.lang.reflect.Method.invoke(Method.java:511)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-03 15:01:18.371: E/AndroidRuntime(7423):     at dalvik.system.NativeStart.main(Native Method)
添加Jars后的

新错误日志:

03-03 15:15:09.472: E/AndroidRuntime(8203): FATAL EXCEPTION: main
03-03 15:15:09.472: E/AndroidRuntime(8203): java.lang.NoClassDefFoundError: com.facebook.SharedPreferencesTokenCachingStrategy
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.parse.auth.FacebookAuthenticationProvider.authenticate(FacebookAuthenticationProvider.java:114)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.parse.ParseUser.authenticateAsync(ParseUser.java:1096)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.parse.ParseUser.logInWithAsync(ParseUser.java:1113)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.parse.ParseUser.logInWithAsync(ParseUser.java:938)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.parse.ParseFacebookUtils.logIn(ParseFacebookUtils.java:338)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.parse.ParseFacebookUtils.logIn(ParseFacebookUtils.java:363)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.example.chartviewer.FbLoginActivity.onCreate(FbLoginActivity.java:44)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.app.Activity.performCreate(Activity.java:5008)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.os.Looper.loop(Looper.java:137)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at android.app.ActivityThread.main(ActivityThread.java:4745)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at java.lang.reflect.Method.invokeNative(Native Method)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at java.lang.reflect.Method.invoke(Method.java:511)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-03 15:15:09.472: E/AndroidRuntime(8203):     at dalvik.system.NativeStart.main(Native Method)

2 个答案:

答案 0 :(得分:4)

请务必选中Java Build Path - >中的复选框。 Order and Export - 标签

enter image description here (图片来自here

答案 1 :(得分:0)

我通过改变我的minSdkVersion(11到8)来获得解决方案