5

我目前正在使用 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)

添加罐子后的新错误日志:

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)
4

2 回答 2

4

确保选中Java Build Path-> Order and Export-tab 中的复选框。

在此处输入图像描述 (图片来自这里

于 2013-03-03T15:10:10.513 回答
0

我通过更改 minSdkVersion(11 到 8) 得到了解决方案

于 2015-02-27T11:35:10.213 回答