java.lang.StackOverflowError:堆栈大小为8MB FirebaseAuth

时间:2017-08-08 21:50:31

标签: java android firebase firebase-authentication android-facebook

我正在使用Firebase创建登录Facebook。我正在使用Facebook Sdk和AccountKit与Firebase Auth。在所有事情都顺利运行之前,我曾与Firebase Auth合作过几十个项目。这次我也在使用AccountKit。

这是我用facebook登录并检索访问令牌的传统代码。

mAuth = FirebaseAuth.getInstance();
        mAuthListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                firebaseAuth.getCurrentUser();
            }
        };
        mCallbackManager = CallbackManager.Factory.create();
        facebookLogin.setReadPermissions("email", "public_profile", "user_birthday");
        facebookLogin.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                Log.d(TAG, "facebook:onSuccess:" + loginResult);
                handleFacebookAccessToken(loginResult.getAccessToken());
                Profile profile = Profile.getCurrentProfile();

                if (profile != null) {
                    userId = profile.getId();
                }
            }

            @Override
            public void onCancel() {
                updateUI(null);
            }

            @Override
            public void onError(FacebookException error) {
                updateUI(null);
            }
        });

ActivityResult Code现在同时具有AccountKit Code和Facebook CallbackManager

@Override
    protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mCallbackManager.onActivityResult(requestCode, resultCode, data);
        // confirm that this response matches your request
        if (requestCode == APP_REQUEST_CODE) {
            AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
            if (loginResult.getError() != null) {
                // display login error
                String toastMessage = loginResult.getError().getErrorType().getMessage();
                Toast.makeText(this, toastMessage, Toast.LENGTH_LONG).show();
            } else if (loginResult.getAccessToken() != null) {
                // on successful login, proceed to the account activity
                launchAccountActivity();
            }
        } 
    }

问题出在这里,App在处理AccessToken时崩溃了这个方法。

private void handleFacebookAccessToken(final AccessToken token) {
        Log.d(TAG, "handleFacebookAccessToken:" + token);
        showProgressDialog();

        AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
        mAuth.signInWithCredential(credential).addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
            @Override
            public void onSuccess(AuthResult authResult) {
                updateUI(authResult.getUser());
            }
        });
    }

private void updateUI(final FirebaseUser firebaseUser){
        if (firebaseUser != null) {
            Map<String, Object> updateValues = new HashMap<>();
            Profile profile = Profile.getCurrentProfile();
            if (profile != null) {
                userId = profile.getId();
            }
            updateValues.put("userName", firebaseUser.getDisplayName() != null ? firebaseUser.getDisplayName() : "Anonymous");
            updateValues.put("photo", firebaseUser.getPhotoUrl() != null ? firebaseUser.getPhotoUrl() : null);
            updateValues.put("userId", firebaseUser.getUid());
            updateValues.put("facebookId", userId != null ? userId : null);
            FirebaseUtil.getCustomersRef().child(firebaseUser.getUid()).updateChildren(
                    updateValues,
                    new DatabaseReference.CompletionListener() {
                        @Override
                        public void onComplete(DatabaseError firebaseError, DatabaseReference databaseReference) {
                            if (firebaseError == null) {
                                doPhoneLogin();
                            }
                        }
                    });
        }
    }

这是我的崩溃的Logcat

08-09 14:07:02.571 9962-14870/in.order.craveu D/FA: Connected to remote service
08-09 14:07:02.571 9962-14870/in.order.craveu V/FA: Processing queued up service tasks: 4
08-09 14:07:05.668 9962-10097/in.order.craveu D/FirebaseAuth: Notifying id token listeners about user ( 5mSc7SjIltWWWHWzUJ3AoxkobEW2 ).
08-09 14:07:05.685 9962-9962/in.order.craveu D/FirebaseApp: Notifying auth state listeners.
08-09 14:07:05.685 9962-9962/in.order.craveu D/FirebaseApp: Notified 0 auth state listeners.
08-09 14:07:05.756 9962-9962/in.order.craveu I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:6
08-09 14:07:05.756 9962-9962/in.order.craveu I/DynamiteModule: Selected remote version of com.google.android.gms.firebase_database, version >= 6
08-09 14:07:06.369 9962-9972/in.order.craveu I/art: Background partial concurrent mark sweep GC freed 46716(1878KB) AllocSpace objects, 7(136KB) LOS objects, 39% free, 12MB/20MB, paused 5.432ms total 64.680ms
08-09 14:07:06.435 9962-9962/in.order.craveu D/AndroidRuntime: Shutting down VM
08-09 14:07:06.569 9962-9962/in.order.craveu E/UncaughtException: java.lang.StackOverflowError: stack size 8MB
                                                                      at com.google.android.gms.internal.zg.zzao(Unknown Source)
                                                                      at com.google.android.gms.internal.zg.zzar(Unknown Source)
                                                                      at com.google.android.gms.internal.zh.zzas(Unknown Source)
                                                                      at com.google.android.gms.internal.zg.zzao(Unknown Source)
                                                                      at com.google.android.gms.internal.zg.zzar(Unknown Source)

当我打开应用程序崩溃后,我使用Facebook登录。

0 个答案:

没有答案