'Android: Firebase LogIn failed password is invalid or the user does not have a password

I'm trying to create a simple app with user's profile's using firebase and I've got a problem. Sign Up function works well and I can see registered accounts in my Firebase console, but Sign In doesn't works well. I've got "password is invalid or the user does not have a password." exception. Can anyone help me with this please. My method to LogIn typed below.

 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());
                   }
                }
            });
}

LogCat:

    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.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
05-13 04:49:18.866 10714-10743/? D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 04:49:18.991 10714-10738/com.example.gmachine.mychat D/FA: Connected to remote service
05-13 04:49:18.991 10714-10738/com.example.gmachine.mychat V/FA: Processing queued up service tasks: 4
05-13 04:49:24.124 10714-10738/com.example.gmachine.mychat V/FA: Inactivity, disconnecting from the service
05-13 04:49:28.720 10714-10719/com.example.gmachine.mychat I/art: Do partial code cache collection, code=27KB, data=29KB
05-13 04:49:28.722 10714-10719/com.example.gmachine.mychat I/art: After code cache collection, code=27KB, data=29KB
    Increasing code cache capacity to 128KB
05-13 04:49:30.937 10714-10714/com.example.gmachine.mychat W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
05-13 04:49:33.192 10714-10719/com.example.gmachine.mychat I/art: Do partial code cache collection, code=62KB, data=55KB
    After code cache collection, code=62KB, data=55KB
    Increasing code cache capacity to 256KB
05-13 04:49:34.038 10714-10714/com.example.gmachine.mychat W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
05-13 04:49:38.664 10714-10714/com.example.gmachine.mychat W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86
05-13 04:49:38.664 10714-10714/com.example.gmachine.mychat D/ApplicationLoaders: ignored Vulkan layer search path /system/priv-app/PrebuiltGmsCore/lib/x86:/system/fake-libs:/system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk!/lib/x86:/system/lib:/vendor/lib for namespace 0xa9d54090
05-13 04:49:38.695 10714-10714/com.example.gmachine.mychat W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-13 04:49:38.695 10714-10714/com.example.gmachine.mychat W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@1b80aea
05-13 04:49:38.717 10714-10988/com.example.gmachine.mychat W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-13 04:49:38.723 10714-10988/com.example.gmachine.mychat I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
    [FirebaseAuth:] Preparing to create service connection to gms implementation
05-13 04:49:39.351 10714-10714/com.example.gmachine.mychat D/z: onComplete: Failed=The password is invalid or the user does not have a password.
05-13 04:49:39.493 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 04:49:39.529 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 04:54:38.844 10714-10988/com.example.gmachine.mychat I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
    [FirebaseAuth:] Preparing to create service connection to gms implementation
05-13 05:02:01.317 10714-10739/com.example.gmachine.mychat W/System: ClassLoader referenced unknown path: /data/data/com.example.gmachine.mychat/lib
05-13 05:02:01.346 10714-19878/com.example.gmachine.mychat V/FA: Recording user engagement, ms: 762757
05-13 05:02:01.347 10714-19878/com.example.gmachine.mychat V/FA: Connecting to remote service
05-13 05:02:01.348 10714-19878/com.example.gmachine.mychat V/FA: Activity paused, time: 29018004
05-13 05:02:01.408 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:01.416 10714-19878/com.example.gmachine.mychat D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=762757, firebase_screen_class(_sc)=LogIn, firebase_screen_id(_si)=-7531630852293217533}]
05-13 05:02:01.535 10714-10714/com.example.gmachine.mychat V/FA: onActivityCreated
05-13 05:02:01.538 10714-19878/com.example.gmachine.mychat V/FA: Connection attempt already in progress
05-13 05:02:01.663 10714-19878/com.example.gmachine.mychat V/FA: Connection attempt already in progress
    Activity resumed, time: 29018325
05-13 05:02:02.308 10714-19878/com.example.gmachine.mychat D/FA: Connected to remote service
05-13 05:02:02.308 10714-19878/com.example.gmachine.mychat V/FA: Processing queued up service tasks: 3
05-13 05:02:02.310 10714-10714/com.example.gmachine.mychat I/Choreographer: Skipped 33 frames!  The application may be doing too much work on its main thread.
05-13 05:02:02.317 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:02.380 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:02.393 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:07.340 10714-19878/com.example.gmachine.mychat V/FA: Inactivity, disconnecting from the service
05-13 05:02:11.505 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:11.772 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:13.726 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:14.138 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:29.855 10714-10714/com.example.gmachine.mychat W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
05-13 05:02:29.940 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:30.353 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:33.796 10714-10714/com.example.gmachine.mychat W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@1b80aea
05-13 05:02:33.797 10714-10988/com.example.gmachine.mychat W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-13 05:02:33.797 10714-10988/com.example.gmachine.mychat I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
    [FirebaseAuth:] Preparing to create service connection to gms implementation
05-13 05:02:34.840 10714-10714/com.example.gmachine.mychat D/z: onComplete: Failed=The password is invalid or the user does not have a password.
05-13 05:02:34.889 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:02:34.913 10714-10743/com.example.gmachine.mychat D/EGL_emulation: eglMakeCurrent: 0xa9b858a0: ver 2 0 (tinfo 0x8c54b1d0)
05-13 05:07:33.860 10714-10988/com.example.gmachine.mychat I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
    [FirebaseAuth:] Preparing to create service connection to gms implementation


Solution 1:[1]

I'd the same problem only to realize later that the I'd initialized the password field with a wrong resource id. Make sure these are correct

Solution 2:[2]

TL;DR:

Check that you are passing a string value and not a reference to your EditText.

Verbose:

In my case, the problem was that I was passing an Edittext reference as the password parameter in FirebaseAuth.createUserWithEmailAndPassword() instead of a String. To put it in context, I was doing:

mAuth.createUserWithEmailAndPassword(validEmail, edittext.text)

instead of

mAuth.createUserWithEmailAndPassword(validEmail, edittext.text.toString())

A lot of users had already been created with an edittext.text reference instead of the password they inputted. That was why they were getting the error anytime they tried to log in with the password they actually chose.

Solution 3:[3]

i have use this code and its working fine.and also check your firebase authentication rule part where must be email and password enable .

    FirebaseAuth mAuth;
      mAuth = FirebaseAuth.getInstance();


   final String email=username.getText().toString();
        final String password=pass.getText().toString();
        Log.d("12345",email+password);
        if(email.equals("")||password.equals(""))
            Toast.makeText(LogIn.this,"Fill both",Toast.LENGTH_SHORT).show();
        else
        {
            mProgressDialog.setMessage("Login....");
            mProgressDialog.show();
            mAuth.signInWithEmailAndPassword(email, password)
                    .addOnCompleteListener(LogIn.this, new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            if (task.isSuccessful()) {
                                // Sign in success, update UI with the signed-in user's information
                                Log.d("12345", "signInWithEmail:success");


                                    Toast.makeText(LogIn.this,"valid email",Toast.LENGTH_LONG).show();

                                mProgressDialog.dismiss();
                                //updateUI(user);
                            } else {
                                // If sign in fails, display a message to the user.
                                Log.w("12345", "signInWithEmail:failure", task.getException());
                                mProgressDialog.dismiss();
                                Toast.makeText(LogIn.this, "Authentication failed.",
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
        }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zoe stands with Ukraine
Solution 2 Taslim Oseni
Solution 3 Aman Khandelwal