App crashes after first Facebook Login

南楼画角 提交于 2019-12-03 07:13:44

Facebook just released v3.5.1 of their Android SDK yesterday that addresses your issues. Their Change Log doesn't give much information about what went wrong, but people have been reporting this bug and they did say it would be fixed in a later version (source). But anyway, looking at the diffs between v3.5 and v3.5.1 they seem to have fixed code around lines 135 and 519. Check out the Change Log the complete list. Probably a good idea never to upgrade to a significant version from Facebook until they release their first patch to it.

I got the same issue today. It seems Facebook SDK 3.5 might not be compatible with old Facebook clients such as Facebook 2.1. I updated Facebook client to the latest version and then it works.

 09-13 17:50:43.592   11372.11372                 Bundle  W  Key com.facebook.platform.protocol.PROTOCOL_VERSION expected String but value was a java.lang.Integer.  The default
                                                              value <null> was returned.
 09-13 17:50:43.602   11372.11372                 Bundle  W  Attempt to cast generated internal exception:
 09-13 17:50:43.602   11372.11372                 Bundle  W  java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.os.Bundle.getString(Bundle.java:1085)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.content.Intent.getStringExtra(Intent.java:4826)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.facebook.AuthorizationClient$KatanaLoginDialogAuthHandler.tryAuthorize(AuthorizationClient.java:821)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:272)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:238)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:161)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:142)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.facebook.LoginActivity.onResume(LoginActivity.java:117)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1282)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.Activity.performResume(Activity.java:5287)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3211)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3266)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2579)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.ActivityThread.access$600(ActivityThread.java:162)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1413)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.os.Handler.dispatchMessage(Handler.java:99)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.os.Looper.loop(Looper.java:158)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at android.app.ActivityThread.main(ActivityThread.java:5789)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at java.lang.reflect.Method.invokeNative(Native Method)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at java.lang.reflect.Method.invoke(Method.java:525)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
 09-13 17:50:43.602   11372.11372                 Bundle  W     at dalvik.system.NativeStart.main(Native Method)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E  FATAL EXCEPTION: main
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E  java.lang.RuntimeException: Unable to resume activity {com.mycomp.myapp/com.facebook.LoginActivity}: java.lang.NullPointe
                                                             rException
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3228)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3266)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2579)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4258)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread.access$700(ActivityThread.java:162)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1419)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.os.Handler.dispatchMessage(Handler.java:99)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.os.Looper.loop(Looper.java:158)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread.main(ActivityThread.java:5789)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at java.lang.reflect.Method.invokeNative(Native Method)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at java.lang.reflect.Method.invoke(Method.java:525)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at dalvik.system.NativeStart.main(Native Method)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E  Caused by: java.lang.NullPointerException
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:135)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at com.facebook.LoginActivity.onResume(LoginActivity.java:117)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1282)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.Activity.performResume(Activity.java:5287)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3211)
 09-13 17:50:43.803   11372.11372         AndroidRuntime  E     ... 13 more

Recently, I have same problem, however, I update the facebook sdk to 3.5.2 version from https://github.com/facebook/facebook-android-sdk and any problem about loggining have been solved.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!