title: Firebase Google Sign In Not Working In Android 11 (Red Velvet Cake)
body: <p>I am creating a Sign In Activity using Firebase authentication. It work successfully on Android Lollipop and on android Pie. However, if I run it on android 11 (Red Velvet), it doesnt work and I got the following message when i hit the login button:</p>
  <pre><code>2022-01-13 19:27:13.842 8122-8122/com.example.riset_login_firebase W/GoogleActivity: Google sign in failed
  
  com.google.android.gms.common.api.ApiException: 12500: 
    at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base@@17.5.0:4)
    at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(com.google.android.gms:play-services-auth@@19.2.0:3)
    at com.example.riset_login_firebase.MainActivity.onActivityResult(MainActivity.java:72)
  </code></pre>
  <p>And here is my code</p>
  <p><strong>MainActivity.java</strong></p>
  <pre><code>package com.example.riset_login_firebase;
  
  import androidx.annotation.NonNull;
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Toast;
  
  import com.google.android.gms.auth.api.signin.GoogleSignIn;
  import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
  import com.google.android.gms.auth.api.signin.GoogleSignInClient;
  import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
  import com.google.android.gms.common.SignInButton;
  import com.google.android.gms.common.api.ApiException;
  import com.google.android.gms.tasks.OnCompleteListener;
  import com.google.android.gms.tasks.Task;
  import com.google.firebase.auth.AuthCredential;
  import com.google.firebase.auth.AuthResult;
  import com.google.firebase.auth.FirebaseAuth;
  import com.google.firebase.auth.FirebaseUser;
  import com.google.firebase.auth.GoogleAuthProvider;
  
  public class MainActivity extends AppCompatActivity {
      SignInButton button;
      private static final String TAG = &quot;GoogleActivity&quot;;
      private static final int RC_SIGN_IN = 9001;
  
      // [START declare_auth]
      private FirebaseAuth mAuth;
      // [END declare_auth]
  
      private GoogleSignInClient mGoogleSignInClient;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Configure Google Sign In
          GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                  .requestIdToken(getString(R.string.default_web_client_id))
                  .requestEmail()
                  .build();
  
          mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
          mAuth = FirebaseAuth.getInstance();
  
          button = findViewById(R.id.login);
          button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  sign();
              }
          });
      }
  
      private void sign() {
          Intent signInIntent = mGoogleSignInClient.getSignInIntent();
          startActivityForResult(signInIntent, RC_SIGN_IN);
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
          if (requestCode == RC_SIGN_IN) {
              Task&lt;GoogleSignInAccount&gt; task = GoogleSignIn.getSignedInAccountFromIntent(data);
              try {
                  // Google Sign In was successful, authenticate with Firebase
                  GoogleSignInAccount account = task.getResult(ApiException.class);
                  Log.d(TAG, &quot;firebaseAuthWithGoogle:&quot; + account.getId());
                  firebaseAuthWithGoogle(account.getIdToken());
              } catch (ApiException e) {
                  // Google Sign In failed, update UI appropriately
                  Log.w(TAG, &quot;Google sign in failed&quot;, e);
              }
          }
      }
  
      private void firebaseAuthWithGoogle(String idToken) {
          AuthCredential credential = GoogleAuthProvider.getCredential(idToken, null);
          mAuth.signInWithCredential(credential)
                  .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                          if (task.isSuccessful()) {
                              // Sign in success, update UI with the signed-in user's information
                              Log.d(TAG, &quot;signInWithCredential:success&quot;);
                              FirebaseUser user = mAuth.getCurrentUser();
                              updateUI(user);
                          } else {
                              // If sign in fails, display a message to the user.
                              Log.w(TAG, &quot;signInWithCredential:failure&quot;, task.getException());
                              updateUI(null);
                          }
                      }
                  });
      }
  
      private void updateUI(FirebaseUser user) {
          if(user != null){
              Toast.makeText(MainActivity.this,&quot;Login Success&quot;,Toast.LENGTH_SHORT).show();
          }
          else{
              Toast.makeText(MainActivity.this,&quot;Login Failed&quot;,Toast.LENGTH_SHORT).show();
          }
      }
  }
  </code></pre>
  <p>Anybody know how to fix it?</p>