All of a sudden firebase authentication not working! Unexpected response code 400

早过忘川 提交于 2019-12-12 04:34:08

问题


My code was working perfectly fine for the last month didn't even touch it for a while for modifications or edits. But now, this problem came up and ruined my app for good. Please help me. The authentication is not working anymore and always fails. Here is my code

    package com.example.niki.responderview;

    import android.app.ActivityManager;
    import android.app.ProgressDialog;
    import android.content.Intent;
    import android.media.MediaPlayer;
    import android.support.annotation.NonNull;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.text.TextUtils;
    import android.util.StringBuilderPrinter;
    import android.view.View;
    import android.view.Window;
    import android.view.accessibility.AccessibilityManager;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ProgressBar;
    import android.widget.TextView;
    import android.widget.Toast;

    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 MainActivity extends AppCompatActivity implements 
    View.OnClickListener{

private Button buttonSignIn;
private EditText editTextEmail;
private EditText editTextPassword;
private TextView textViewSignUp;
private ProgressDialog progressDialog;
private FirebaseAuth firebaseAuth;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    buttonSignIn = (Button) findViewById(R.id.buttonSignIn);
    editTextEmail = (EditText) findViewById(R.id.editTextEmail);
    editTextPassword = (EditText) findViewById(R.id.editTextPassword);
    textViewSignUp = (TextView) findViewById(R.id.textViewSignUp);

    progressDialog = new ProgressDialog(this);
    firebaseAuth = FirebaseAuth.getInstance();

    //if user is already login or not
    if(firebaseAuth.getCurrentUser() != null){
        //profile activity
        finish();
        startActivity(new Intent(getApplicationContext(), ViewUsers.class ));
    }

    buttonSignIn.setOnClickListener(this);
    textViewSignUp.setOnClickListener(this);
}

private void userLogin(){
    String email = editTextEmail.getText().toString().trim();
    String password = editTextPassword.getText().toString().trim();

    if(TextUtils.isEmpty(email)){
        //does not give email address
        Toast.makeText(this, "Please enter your Email Address", Toast.LENGTH_SHORT).show();
        //stop further execution
        return;
    }

    if(TextUtils.isEmpty(password)){
        //if password is empty
        Toast.makeText(this, "Please enter your password", Toast.LENGTH_SHORT).show();
        //stop execution
        return;
    }
    //if the requirements are satisfied
    progressDialog.setMessage("Logging In ..");
    progressDialog.show();

    firebaseAuth.signInWithEmailAndPassword(email,password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task){
                    if(task.isSuccessful()){
                        //user successfully registered
                        finish();
                        startActivity(new Intent(getApplicationContext(), ViewUsers.class ));
                    }else{
                        Toast.makeText(MainActivity.this, "Failed to Log in. Please try again", Toast.LENGTH_SHORT).show();
                        progressDialog.dismiss();
                    }
                }
            });

}
@Override
public void onClick(View view){
    if(view == buttonSignIn){
        //login user
        userLogin();
        //startActivity(new Intent(this, CurrentLocationActivity.class));
    }
    if(view == textViewSignUp){
        startActivity(new Intent(this, SignUpActivity.class));
    }
}

}

I'm using a simple email and password for authentication it was also enabled in the console.I don't know what to do, and I need to get it done.

Here's the error

    05-24 11:47:51.330 4162-2069/com.google.android.gms E/Herrevad: [276] 
    RemoteReportsRefreshChimeraService.a: want to send authenticated 
    request, but no Google account on device
    05-24 11:47:51.762 4162-4483/com.google.android.gms E/Volley: [131] 
    BasicNetwork.performRequest: Unexpected response code 307 for 
    https://android.googleapis.com/nova/herrevad/network_quality_info
    05-24 11:47:51.961 4162-17005/com.google.android.gms E/Volley: [257] 
    BasicNetwork.performRequest: Unexpected response code 400 for       
  https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?
    key=AIzaSyDdcFHJ9RTBrw1J0w2jtUEOhTHC7Jmi3_A

回答1:


In your Log its showing 'want to send authenticated request, but no Google account on device'. Is this crash is coming for every device. I prefer you test this in other devices.



来源:https://stackoverflow.com/questions/44148710/all-of-a-sudden-firebase-authentication-not-working-unexpected-response-code-40

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!