facebook / facebook-android-sdk

Used to integrate Android apps with Facebook Platform.
https://developers.facebook.com/docs/android
Other
6.17k stars 3.66k forks source link

KatanaProxyLoginMethodHandler.tryAuthorize java.lang.NullPointerException - Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object referenc #1219

Open ZhangZhizhen opened 1 year ago

ZhangZhizhen commented 1 year ago

Checklist before submitting a bug report

Java version

java11

Android version

Android 13,level 33

Android SDK version

15.0.2

Installation platform & version

google 商店

Package

Login

Goals

登录正常

Expected results

facebook登录过程中不发生崩溃

Actual results

KatanaProxyLoginMethodHandler.tryAuthorize java.lang.NullPointerException - Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference

Caused by java.lang.NullPointerException Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference com.facebook.login.KatanaProxyLoginMethodHandler.tryAuthorize (KatanaProxyLoginMethodHandler.kt:64) com.facebook.login.LoginClient.tryCurrentHandler (LoginClient.kt:260) com.facebook.login.LoginClient.tryNextHandler (LoginClient.kt:211) com.facebook.login.LoginClient.authorize (LoginClient.kt:106) com.facebook.login.LoginClient.startOrContinueAuth (LoginClient.kt:89) com.facebook.login.LoginFragment.onResume (LoginFragment.kt:154) androidx.fragment.app.Fragment.performResume (Fragment.java:3026) androidx.fragment.app.FragmentStateManager.resume (FragmentStateManager.java:604) androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:306) androidx.fragment.app.FragmentStore.moveToExpectedState (FragmentStore.java:112) androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:1636) androidx.fragment.app.FragmentManager.dispatchStateChange (FragmentManager.java:3112) androidx.fragment.app.FragmentManager.dispatchResume (FragmentManager.java:3070) androidx.fragment.app.FragmentController.dispatchResume (FragmentController.java:273) androidx.fragment.app.FragmentActivity.onResumeFragments (FragmentActivity.java:434) androidx.fragment.app.FragmentActivity.onPostResume (FragmentActivity.java:423) android.app.Activity.performResume (Activity.java:8759) android.app.ActivityThread.performResumeActivity (ActivityThread.java:5351) android.app.ActivityThread.handleResumeActivity (ActivityThread.java:5444) android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:54) android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45) android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176) android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97) android.app.ActivityThread$H.handleMessage (ActivityThread.java:2574) android.os.Handler.dispatchMessage (Handler.java:106) android.os.Looper.loopOnce (Looper.java:226) android.os.Looper.loop (Looper.java:313) android.app.ActivityThread.main (ActivityThread.java:8757) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)

Steps to reproduce

facebook 登录

Code samples & details

// INSERT YOUR CODE HERE

 LoginManager.getInstance().logOut();
 AccessToken accessToken = AccessToken.getCurrentAccessToken();
 boolean isLoggedIn = accessToken != null && !accessToken.isExpired();
 if(isLoggedIn){
      String id = accessToken.getUserId();
      String idToken = accessToken.getToken();
      String displayName = "";
      String email = "";
      String authCode = "";
      listener.onSuccess(id,displayName,email,idToken,authCode);
    } else {
       LoginManager.getInstance().logInWithReadPermissions((Activity) this.context, Arrays.asList("public_profile","email","user_friends"));
     }

 public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(callbackManager == null){
            callbackManager = CallbackManager.Factory.create();
            LoginManager.getInstance().registerCallback(callbackManager,
                    new FacebookCallback<LoginResult>() {
                        @Override
                        public void onSuccess(LoginResult loginResult) {
                            // App code
                            accessToken = loginResult.getAccessToken();
                            String id = accessToken.getUserId();
                            String idToken = accessToken.getToken();
                            String displayName = "";
                            String email = "";
                            String authCode = "";
                            if(listener == null){
                                return;
                            }
                            listener.onSuccess(id,displayName,email,idToken,authCode);
                        }

                        @Override
                        public void onCancel() {
                            // App code
                        }

                        @Override
                        public void onError(FacebookException exception) {
                            // App code
                        }
                    });
        }
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }