You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Firebase登录失败:密码无效或用户无密码问题求助

Hey there, let's work through why your Firebase login is throwing that "password is invalid or the user does not have a password" error. I’ve looked over your code and logs, here are the most likely fixes to try:

1. Confirm How the User Account Was Created

First, jump into your Firebase Console > Authentication > Users. Check the Provider column for the account you’re trying to log into. If it’s not listed as password, that means the account was created via another method (like anonymous auth, Google sign-in, etc.)—those accounts don’t have a password linked, so email/password login will fail every time.

Double-check your registration code to make sure it’s using createUserWithEmailAndPassword(email, password) correctly, and that you’re passing the user’s input password directly (no accidental modifications) when creating the account.

2. Check Password Consistency & Input Handling

  • Firebase passwords are case-sensitive—make sure the password you enter during login matches exactly (uppercase/lowercase) what was used during registration.
  • Compare your registration logic to your login code: your login code uses trim() on the password, but if registration doesn’t do the same, a password with leading/trailing spaces from registration won’t match the trimmed version during login.

3. Clear Existing Auth Session

Cached user sessions can sometimes cause odd behavior. Try adding a sign-out call before running your login logic to reset the auth state:

firebaseAuth.signOut();
// Then execute your userLogin() method

4. Debug the Input Values

Add a quick log statement in your userLogin() method to confirm the exact email and password being sent to Firebase—this will rule out issues with input fields not capturing the right values:

Log.d("LoginDebug", "Attempting login with Email: " + email + ", Password: " + password);

5. Verify Firebase Auth Configuration

Quickly confirm that Email/Password sign-in is enabled in your Firebase Console > Authentication > Sign-in method. Even if you can create accounts, disabling this later will break login (your error message doesn’t point to this, but it’s a quick check to eliminate possibilities).


Your Login Code (Formatted)

private void userLogin(){ 
    String email = emailText.getText().toString().trim(); 
    String password = passwordText.getText().toString().trim(); 

    if (TextUtils.isEmpty(email)){ 
        Toast.makeText(this,"Please enter email", Toast.LENGTH_SHORT).show(); 
        return; 
    } 
    if (TextUtils.isEmpty(password)) { 
        Toast.makeText(this,"Please enter password", Toast.LENGTH_SHORT).show(); 
        return; 
    } 

    firebaseAuth.signInWithEmailAndPassword(email, password) 
        .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { 
            @Override 
            public void onComplete(@NonNull Task<AuthResult> task) { 
                if(task.isSuccessful()){ 
                    Toast.makeText(LogIn.this,"You are logged in", Toast.LENGTH_SHORT).show(); 
                } else{ 
                    Toast.makeText(LogIn.this,"MISTAKE", Toast.LENGTH_SHORT).show(); 
                    Log.d("z", "onComplete: Failed=" + task.getException().getMessage()); 
                } 
            } 
        }); 
}

Your LogCat Output

05-13 04:49:17.944 10714-10714/? I/art: Not late-enabling -Xcheck:jni (already on) 
05-13 04:49:17.944 10714-10714/? W/art: Unexpected CPU variant for X86 using defaults: x86 
05-13 04:49:17.964 10714-10721/? E/art: Failed sending reply to debugger: Broken pipe 
05-13 04:49:17.964 10714-10721/? I/art: Debugger is no longer active Starting a blocking GC Instrumentation 
05-13 04:49:18.144 10714-10714/? W/System: ClassLoader referenced unknown path: /data/app/com.example.gmachine.mychat-1/lib/x86 
05-13 04:49:18.231 10714-10714/? D/FirebaseAuth: Notifying id token listeners about user ( KUXl4u7sy6OdwE0P3fmCRWyHugz1 ). 
05-13 04:49:18.250 10714-10714/? D/FirebaseAuth: Notifying id token listeners about user ( KUXl4u7sy6OdwE0P3fmCRWyHugz1 ). 
05-13 04:49:18.258 10714-10714/? D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization. 
05-13 04:49:18.324 10714-10714/? V/FA: Registered activity lifecycle callback 
05-13 04:49:18.328 10714-10714/? I/FirebaseInitProvider: FirebaseApp initialization successful 
05-13 04:49:18.333 10714-10714/? I/InstantRun: starting instant run server: is main process 
05-13 04:49:18.354 10714-10738/? V/FA: Collection enabled App package, google app id: com.example.gmachine.mychat, 1:411464926772:android:67ab72bb5465b580 
05-13 04:49:18.354 10714-10738/? I/FA: App measurement is starting up, version: 12451 To enable debug logging run: adb shell setprop log.tag.FA VERBOSE 
05-13 04:49:18.355 10714-10738/? I/FA: To enable faster debug mode event logging run: adb shell setprop debug.firebase.analytics.app com.example.gmachine.mychat 
05-13 04:49:18.355 10714-10738/? D/FA: Debug-level message logging enabled 
05-13 04:49:18.372 10714-10738/? V/FA: Cancelling job. JobID: 67470213 
05-13 04:49:18.424 10714-10714/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 
05-13 04:49:18.430 10714-10738/? V/FA: Connecting to remote service 
05-13 04:49:18.432 10714-10714/? V/FA: onActivityCreated 
05-13 04:49:18.503 10714-10738/? V/FA: Connection attempt already in progress 
05-13 04:49:18.590 10714-10738/? I/FA: Tag Manager is not found and thus will not be used 
05-13 04:49:18.600 10714-10738/? D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=LogIn, firebase_screen_id(_si)=-7531630852293217533}] 
05-13 04:49:18.617 10714-10738/? V/FA: Connection attempt already in progress 
05-13 04:49:18.618 10714-10738/? V/FA: Connection attempt already in progress 
05-13 04:49:18.622 10714-10738/? V/FA: Activity resumed, time: 28255253 
05-13 04:49:18.650 10714-10714/? D/FirebaseApp: Notifying auth state listeners. Notified 0 auth state listeners. 
05-13 04:49:18.651 10714-10714/? D/FirebaseApp: Notifying auth state listeners. Notified 0 auth state listeners. 
05-13 04:49:18.736 10714-10743/? I/OpenGLRenderer: Initialized EGL, version 1.4 
05-13 04:49:18.736 10714-10743/? D/OpenGLRenderer: Swap behavior 1 
05-13 04:49:18.737 10714-10743/? W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 
05-13 04:49:18.737 10714-10743/? D/OpenGLRenderer: Swap behavior 0 
05-13 04:49:18.758 10714-10743/? D/EGL_emulation: eglCreateContext: 0xa9b858a0: maj 2 min 0 rcv 2 
05-13 04:49:18.818 10714-10743/? D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0) 
05-13 04:49:18.858 10714-10714/? W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSele

内容的提问来源于stack exchange,提问作者Grigory Shimichev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:36:06