title: Google Sign-in in android app not working now
body: <p>I was developing an android app which uses google sign-in process (which was already integrated into my app). It worked for me some months ago but doesn't work now(google updates some policies or whatever!). Can anyone suggest what is going on here? Thanks in advance.
  Here's my code for integrating google sign-in process:</p>
  
  <pre><code>public class login extends AppCompatActivity {
  
  private SignInButton signInButton;
  private TextView textView, signT;
  private static final int SIGNIN_CODE = 1;
  private GoogleApiClient mGoogleApiClient;
  private FirebaseAuth mAuth;
  private FirebaseAuth.AuthStateListener mAuthListener;
  
  private final static String TAG = "Login Info:";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_login);
  
      mAuth = FirebaseAuth.getInstance();
      mAuthListener = new FirebaseAuth.AuthStateListener() {
          @Override
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
              if (firebaseAuth.getCurrentUser() != null) {
                  Intent i = new Intent(getApplicationContext(), MainActivity.class);
                  i.putExtra("Val", "That i need");
                  startActivity(i);
                  overridePendingTransition(R.anim.fadein, R.anim.fadeout);
                  finish();
              }
          }
      };
  
      signInButton = findViewById(R.id.SignIn);
  
      signT = (TextView) signInButton.getChildAt(0);
      signT.setText("Sign in with Google");
  
      textView = findViewById(R.id.negativetext);
      textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
      textView.setText(getString(R.string.negativetext));
  
      textView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent i = new Intent(getApplicationContext(), MainActivity.class);
              startActivity(i);
              overridePendingTransition(R.anim.fadein, R.anim.fadeout);
              finish();
          }
      });
  
      GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
              .requestIdToken(getString(R.string.default_web_client_id))
              .requestEmail()
              .build();
  
      mGoogleApiClient = new GoogleApiClient.Builder(this)
              .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
                  @Override
                  public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                      Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
                  }
              })
              .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
              .build();
  
      signInButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              signIn();
          }
      });
  
  }
  
  
  @Override
  protected void onStart() {
      super.onStart();
      mAuth.addAuthStateListener(mAuthListener);
  }
  
  private void signIn() {
      Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
      startActivityForResult(signInIntent, SIGNIN_CODE);
  }
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == SIGNIN_CODE) {
          Task&lt;GoogleSignInAccount&gt; task = GoogleSignIn.getSignedInAccountFromIntent(data);
          try {
              // Authenicate with my Firebase
              GoogleSignInAccount account = task.getResult(ApiException.class);
              ProgressDialog dialog = new ProgressDialog(this); //ProgressDialog.show(this, null, "Please wait while we load sign in..", true);
              dialog.setMessage("Please wait while we load sign in..");
              dialog.setIndeterminate(true);
              Drawable drawable = new ProgressBar(this).getIndeterminateDrawable().mutate();
              drawable.setColorFilter(ContextCompat.getColor(this, R.color.progress),
                                      PorterDuff.Mode.SRC_IN);
              dialog.setIndeterminateDrawable(drawable);
              dialog.show();
  
              firebaseAuthWithGoogle(account);
          } catch (ApiException e) {
              // Google Sign In failed?
              Log.w(TAG, "Google sign in failed", e);
          }
      }
  }
  
  private void firebaseAuthWithGoogle(final GoogleSignInAccount acct) {
  
      AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
  
      mAuth.signInWithCredential(credential)
              .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                  @Override
                  public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                      //Debugging :(
                      //Toast.makeText(getApplicationContext(), "" + task.isSuccessful(), Toast.LENGTH_LONG).show();
                      if (task.isSuccessful()) {
                          //spinner.setVisibility(ProgressBar.INVISIBLE);
                          Log.i(TAG, "signInWithCredential:success");
                      } else {
                          Toast.makeText(getApplicationContext(), "We couldn't load sign in", Toast.LENGTH_LONG).show();
                      }
                  }
              });
  }}
  </code></pre>