result.isSuccess() return false - GoogleLogin with Android

I am doing an application in android studio and I want to add logueo with Google … but it always returns false the following code:

private void handleSignInResult(GoogleSignInResult result) {
        //If the login succeed
        if (result.isSuccess()) {
            //Getting google account
            GoogleSignInAccount acct = result.getSignInAccount();

            //Displaying name and email
            textViewName.setText(acct.getDisplayName());
            textViewEmail.setText(acct.getEmail());

        } else {
            //If login fails
            Toast.makeText(this, "Login Failed", Toast.LENGTH_LONG).show();
        }
    }

I always get the message back “Login Failed”

What should I do?

Instead of “Login Failed” maybe using getStatusCode() or getStatusMessage() would be more helpful for debugging purposes?

Use isSuccess() to determine whether the call was successful, and getStatusCode() to determine what the error cause was.

yes, I agree with @Mittineague

you can use getStatusCode() to find what exactly the error is.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.