奇怪的FirebaseUI身份验证(使用电子邮件):第二次登录成功后,第一次登录失败

时间:2017-02-09 17:22:32

标签: android firebase firebase-authentication firebaseui

我正在使用FirebaseUI身份验证进行登录过程。在这里我遇到了一个非常奇怪的问题:

当我使用电子邮件登录时,“让我输入我的电子邮件”,“检查电子邮件帐户是否已存在”以及“让我输入我的密码”等功能都很好,但在我发送密码后,我无法登录,FirebaseUI auth活动重新开始。但是,如果我尝试使用AGAIN电子邮件登录,我会在第二次尝试时成功登录。

我已经多次测试过,并且总是得到相同的结果。每第一次失败,而第二次失败,而第二次失败。不知道为什么会这样。有人可以帮忙吗?谢谢!

这是我的logcat:

第一次登录(失败)

02-09 21:39:45.599 20008-3407/com.einsambr.bridge_1_0 V/FA: Recording user engagement, ms: 66377
02-09 21:39:45.600 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:39:45.600 20008-3407/com.einsambr.bridge_1_0 V/FA: Connecting to remote service
02-09 21:39:45.605 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity paused, time: 24483951
02-09 21:39:45.610 20008-20008/com.einsambr.bridge_1_0 V/FA: onActivityCreated
02-09 21:39:45.612 20008-3407/com.einsambr.bridge_1_0 D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=66377, _sc=AuthMethodPickerActivity, _si=-452943598100446909}]
02-09 21:39:45.634 20008-20008/com.einsambr.bridge_1_0 D/AutoManageHelper: starting AutoManage for client 3 false false
02-09 21:39:45.645 20008-20008/com.einsambr.bridge_1_0 D/AutoManageHelper: onStart true {3=com.google.android.gms.internal.zzzt$zza@eca98fe}
02-09 21:39:45.680 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:39:45.680 20008-3407/com.einsambr.bridge_1_0 V/FA: Connection attempt already in progress
02-09 21:39:45.681 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:39:45.681 20008-3407/com.einsambr.bridge_1_0 V/FA: Connection attempt already in progress
02-09 21:39:45.682 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity resumed, time: 24484001
02-09 21:39:45.719 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:39:45.719 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x986a78e0, error=EGL_BAD_MATCH
02-09 21:39:45.807 20008-3407/com.einsambr.bridge_1_0 V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 160
02-09 21:39:45.807 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:39:45.807 20008-3407/com.einsambr.bridge_1_0 V/FA: Connection attempt already in progress
02-09 21:39:45.808 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity paused, time: 24484161
02-09 21:39:46.158 20008-3407/com.einsambr.bridge_1_0 D/FA: Connected to remote service
02-09 21:39:46.158 20008-3407/com.einsambr.bridge_1_0 V/FA: Processing queued up service tasks: 4
02-09 21:39:46.441 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b427e0
02-09 21:39:46.475 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity resumed, time: 24484824
02-09 21:39:51.477 20008-3407/com.einsambr.bridge_1_0 V/FA: Inactivity, disconnecting from the service
02-09 21:40:00.510 20008-20042/com.einsambr.bridge_1_0 W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-09 21:40:00.513 20008-20042/com.einsambr.bridge_1_0 W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-09 21:40:00.557 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:00.557 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x97931fc0, error=EGL_BAD_MATCH

第二次登录(成功)

02-09 21:40:06.428 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b435e0
02-09 21:40:06.454 20008-3407/com.einsambr.bridge_1_0 V/FA: Recording user engagement, ms: 19984
02-09 21:40:06.455 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:40:06.455 20008-3407/com.einsambr.bridge_1_0 V/FA: Connecting to remote service
02-09 21:40:06.459 20008-3407/com.einsambr.bridge_1_0 D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=19984, _sc=RegisterEmailActivity, _si=-452943598100446908}]
02-09 21:40:06.471 20008-20008/com.einsambr.bridge_1_0 V/FA: onActivityCreated
02-09 21:40:06.516 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:40:06.516 20008-3407/com.einsambr.bridge_1_0 V/FA: Connection attempt already in progress
02-09 21:40:06.516 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity paused, time: 24504812
02-09 21:40:06.521 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:40:06.521 20008-3407/com.einsambr.bridge_1_0 V/FA: Connection attempt already in progress
02-09 21:40:06.521 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity resumed, time: 24504840
02-09 21:40:06.521 20008-3407/com.einsambr.bridge_1_0 D/FA: Connected to remote service
02-09 21:40:06.521 20008-3407/com.einsambr.bridge_1_0 V/FA: Processing queued up service tasks: 3
02-09 21:40:06.549 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:06.549 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x98695e00, error=EGL_BAD_MATCH
02-09 21:40:06.734 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b43880
02-09 21:40:10.679 20008-20042/com.einsambr.bridge_1_0 W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-09 21:40:11.579 20008-3407/com.einsambr.bridge_1_0 V/FA: Inactivity, disconnecting from the service
02-09 21:40:12.030 20008-20042/com.einsambr.bridge_1_0 W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-09 21:40:12.033 20008-20042/com.einsambr.bridge_1_0 W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-09 21:40:12.066 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:12.066 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x986a59a0, error=EGL_BAD_MATCH
02-09 21:40:12.172 20008-20014/com.einsambr.bridge_1_0 W/art: Suspending all threads took: 18.413ms
02-09 21:40:13.166 20008-20020/com.einsambr.bridge_1_0 D/FirebaseAuth: Notifying listeners about user ( yG39yzzakVMtUqIb2ovDysSG8sj2 ).
02-09 21:40:13.184 20008-20008/com.einsambr.bridge_1_0 D/FirebaseApp: Notifying auth state listeners.
02-09 21:40:13.185 20008-20008/com.einsambr.bridge_1_0 D/FirebaseApp: Notified 1 auth state listeners.
02-09 21:40:13.185 20008-20008/com.einsambr.bridge_1_0 D/AutoManageHelper: starting AutoManage for client 2 false false
02-09 21:40:13.206 20008-20008/com.einsambr.bridge_1_0 D/AutoManageHelper: onStart true {2=com.google.android.gms.internal.zzzt$zza@974694}
02-09 21:40:13.291 20008-20008/com.einsambr.bridge_1_0 W/SaveSmartLock: No eligible accounts can be found
02-09 21:40:13.317 20008-3407/com.einsambr.bridge_1_0 V/FA: Recording user engagement, ms: 6831
02-09 21:40:13.317 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:40:13.317 20008-3407/com.einsambr.bridge_1_0 V/FA: Connecting to remote service
02-09 21:40:13.322 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity paused, time: 24511670
02-09 21:40:13.325 20008-3407/com.einsambr.bridge_1_0 D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=6831, _sc=WelcomeBackPasswordPrompt, _si=-452943598100446907}]
02-09 21:40:13.398 20008-3407/com.einsambr.bridge_1_0 V/FA: Using measurement service
02-09 21:40:13.398 20008-3407/com.einsambr.bridge_1_0 V/FA: Connection attempt already in progress
02-09 21:40:13.467 20008-3407/com.einsambr.bridge_1_0 D/FA: Connected to remote service
02-09 21:40:13.467 20008-3407/com.einsambr.bridge_1_0 V/FA: Processing queued up service tasks: 2
02-09 21:40:13.774 20008-20008/com.einsambr.bridge_1_0 D/AutoManageHelper: onStart true {1=com.google.android.gms.internal.zzzt$zza@1d27f6}
02-09 21:40:13.823 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:13.823 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa047e8c0, error=EGL_BAD_MATCH
02-09 21:40:13.901 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:13.901 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa047e880, error=EGL_BAD_MATCH
02-09 21:40:14.374 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b42a80
02-09 21:40:14.400 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b427e0
02-09 21:40:14.463 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity resumed, time: 24512815
02-09 21:40:14.505 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b44060
02-09 21:40:14.607 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:14.607 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x978da720, error=EGL_BAD_MATCH
02-09 21:40:16.860 20008-3407/com.einsambr.bridge_1_0 V/FA: Recording user engagement, ms: 2399
02-09 21:40:16.861 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity paused, time: 24515213
02-09 21:40:16.862 20008-3407/com.einsambr.bridge_1_0 D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=2399, _sc=MainActivity, _si=-452943598100446929}]
02-09 21:40:16.896 20008-20008/com.einsambr.bridge_1_0 V/FA: onActivityCreated
02-09 21:40:16.986 20008-3407/com.einsambr.bridge_1_0 V/FA: Activity resumed, time: 24515340
02-09 21:40:17.051 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:17.051 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x986a74c0, error=EGL_BAD_MATCH
02-09 21:40:17.282 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b44140
02-09 21:40:17.970 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b438f0
02-09 21:40:18.040 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:18.040 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x98695ce0, error=EGL_BAD_MATCH
02-09 21:40:21.466 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b44060
02-09 21:40:21.504 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:21.504 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x975645e0, error=EGL_BAD_MATCH
02-09 21:40:21.987 20008-3407/com.einsambr.bridge_1_0 V/FA: Inactivity, disconnecting from the service
02-09 21:40:22.088 20008-20042/com.einsambr.bridge_1_0 W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-09 21:40:24.971 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b438f0
02-09 21:40:25.013 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:25.013 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x974ee760, error=EGL_BAD_MATCH
02-09 21:40:28.475 20008-20068/com.einsambr.bridge_1_0 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa1b44060
02-09 21:40:28.517 20008-20068/com.einsambr.bridge_1_0 E/EGL_emulation: tid 20068: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
02-09 21:40:28.517 20008-20068/com.einsambr.bridge_1_0 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x97564840, error=EGL_BAD_MATCH

认证代码:

private FirebaseAuth firebaseAuth;
private FirebaseAuth.AuthStateListener authStateListener;
public static final int RC_SIGN_IN=1;
public static String userUID="";
public static boolean logOut=false;
@Override protected void onCreate(Bundle savedInstanceState)
{
    firebaseAuth= FirebaseAuth.getInstance();
    SetAuthStateListener();        
}
private void SetAuthStateListener()
{
    authStateListener=new FirebaseAuth.AuthStateListener()
    {
        @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth)
        {
            FirebaseUser user=firebaseAuth.getCurrentUser();
            if(user!=null)
            {
                userUID=firebaseAuth.getCurrentUser().getUid();
                Toast.makeText(MainActivity.this,"User Name: "+userUID,Toast.LENGTH_LONG).show();
                //......some stuffs to do                    
            }
            else
            {                   
                startActivityForResult(
                        AuthUI.getInstance()
                                .createSignInIntentBuilder()
                                .setProviders(Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                        new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                                        new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
                                .build(),
                        RC_SIGN_IN);
            }
        }
    };
}
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode==RC_SIGN_IN)
    {
        if(resultCode==RESULT_OK)
        {
            userUID=firebaseAuth.getCurrentUser().getUid();
            Toast.makeText(this,"You are signed in!",Toast.LENGTH_LONG).show();
        }
        else if(resultCode==RESULT_CANCELED)
        {
            Toast.makeText(this,"Sign in cancelled",Toast.LENGTH_LONG).show();
            finish();
        }
    }
}
@Override protected void onResume()
{
    super.onResume();
    firebaseAuth.addAuthStateListener(authStateListener);
    if(logOut)//I set the LOGOUT button in another activity. When it is pressed on, the public static boolean "logout" will be changed to "true", and also the user will be back to MainActivity and actually log-out here in OnReSume() method.
    {
        logOut=false;
        AuthUI.getInstance().signOut(MainActivity.this);
    }
}
@Override protected void onPause()
{
    super.onPause();
    firebaseAuth.removeAuthStateListener(authStateListener);
}

0 个答案:

没有答案