title: Firebase Email and password Authentication fails mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener((task)
body: <p>This is my CustomerLoginRegisterActivity.java that gets customer's Email and password for login and registers email and password to firebase if they don't have an account,</p>
  
  <p>i refered this tutorial : <a href="https://youtu.be/d8JMjBMQaMk?list=PLxefhmF0pcPl6gcWvrpTbjGO7rcMWY1jT" rel="nofollow noreferrer">https://youtu.be/d8JMjBMQaMk?list=PLxefhmF0pcPl6gcWvrpTbjGO7rcMWY1jT</a></p>
  
  <p>But The Firebase authentication fails everytime during registration.
  I've enabled Sign-In method in my Firebase Account</p>
  
  <pre><code> package com.example.saiadarsh.appendly;
  
  import android.app.ProgressDialog;
  import android.support.annotation.NonNull;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.text.TextUtils;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.google.android.gms.common.SignInButton;
  import com.google.android.gms.tasks.OnCompleteListener;
  import com.google.android.gms.tasks.Task;
  import com.google.firebase.auth.AuthResult;
  import com.google.firebase.auth.FirebaseAuth;
  
  public class CustomerLoginRegisterActivity extends AppCompatActivity {
  
      private Button CustomerLoginButton;
      private Button CustomerRegisterButton;
      private TextView CustomerRegisterLink;
      private TextView CustomerStatus;
      private EditText EmailCustomer;
      private EditText PasswordCustomer;
      private ProgressDialog loadingBar;
  
      private FirebaseAuth mAuth;
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_customer_login_register);
  
          mAuth = FirebaseAuth.getInstance();
  
          CustomerLoginButton = (Button) findViewById(R.id.customer_login_btn);
          CustomerRegisterButton = (Button) findViewById(R.id.customer_register_btn);
          CustomerRegisterLink = (TextView) findViewById(R.id.register_customer_link);
          CustomerStatus = (TextView) findViewById(R.id.customer_status);
          EmailCustomer = (EditText) findViewById(R.id.email_customer);
          PasswordCustomer = (EditText) findViewById(R.id.password_customer);
          loadingBar = new ProgressDialog(this);
  
  
  
          CustomerRegisterButton.setVisibility(View.INVISIBLE);
          CustomerRegisterButton.setEnabled(false);
  
          CustomerRegisterLink.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  CustomerLoginButton.setVisibility(View.INVISIBLE);
                  CustomerRegisterLink.setVisibility(View.INVISIBLE);
                  CustomerStatus.setText("Register Customer");
  
                  CustomerRegisterButton.setVisibility(View.VISIBLE);
                  CustomerRegisterButton.setEnabled(true);
              }
          });
  
  
  
          CustomerRegisterButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view)
              {
                  String email = EmailCustomer.getText().toString();
                  String password = PasswordCustomer.getText().toString();
  
                  RegisterCustomer(email, password);
              }
          });
  
          CustomerLoginButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String email = EmailCustomer.getText().toString();
                  String password = PasswordCustomer.getText().toString();
  
                  SignInCustomer(email, password);
              }
          });
      }
  
      private void SignInCustomer(String email, String password)
      {
          if(TextUtils.isEmpty(email))
          {
              Toast.makeText(CustomerLoginRegisterActivity.this, "Please write Email...", Toast.LENGTH_SHORT).show();
          }
          if(TextUtils.isEmpty(password))
          {
              Toast.makeText(CustomerLoginRegisterActivity.this, "Please write Password...", Toast.LENGTH_SHORT).show();
          }
          else
          {
  
              loadingBar.setTitle("Customer Login");
              loadingBar.setMessage("Please wait, while we are on it");
              loadingBar.show();
  
              mAuth.signInWithEmailAndPassword(email, password)
                      .addOnCompleteListener(new OnCompleteListener&lt;AuthResult&gt;() {
                          @Override
                          public void onComplete(@NonNull Task&lt;AuthResult&gt; task)
                          {
                              if(task.isSuccessful())
                              {
                                  Toast.makeText(CustomerLoginRegisterActivity.this, "Customer Login Successfully", Toast.LENGTH_SHORT).show();
                                  loadingBar.dismiss();
                              }
                              else
                              {
                                  Toast.makeText(CustomerLoginRegisterActivity.this, "Login Unsuccessful, Please Try Again.....", Toast.LENGTH_SHORT).show();
                                  loadingBar.dismiss();
                              }
                          }
                      });
          }
      }
  
      private void RegisterCustomer(String email, String password)
      {
          if(TextUtils.isEmpty(email))
          {
              Toast.makeText(CustomerLoginRegisterActivity.this, "Please write Email...", Toast.LENGTH_SHORT).show();
          }
          if(TextUtils.isEmpty(password))
          {
              Toast.makeText(CustomerLoginRegisterActivity.this, "Please write Password...", Toast.LENGTH_SHORT).show();
          }
          else
          {
  
              loadingBar.setTitle("Customer Registration");
              loadingBar.setMessage("Please wait, while we are on it");
              loadingBar.show();
  
              mAuth.createUserWithEmailAndPassword(email, password)
                      .addOnCompleteListener(new OnCompleteListener&lt;AuthResult&gt;() {
                          @Override
                          public void onComplete(@NonNull Task&lt;AuthResult&gt; task)
                          {
                              if(task.isSuccessful())
                              {
                                  Toast.makeText(CustomerLoginRegisterActivity.this, "Customer Registered Successfully", Toast.LENGTH_SHORT).show();
                                  loadingBar.dismiss();
                              }
                              else
                              {
                                  Toast.makeText(CustomerLoginRegisterActivity.this, "Registeration Unsuccessful, Please Try Again.....", Toast.LENGTH_SHORT).show();
                                  loadingBar.dismiss();
                              }
                          }
                      });
          }
      }
  }
  </code></pre>