title: Android: Infinite loop during Google Login
body: <p>My app has been live using Google login for a few years now. I reworked the implementation a few months ago with no issues until recently.
  Now, a few weeks ago, login has stopped working. When I attempt it, the login never finishes, but stays in an infinite loop, displaying the "connecting" screen over and over.</p>
  
  <ul>
  <li>internet connectivity is ok</li>
  <li>this happens to many users (not sure if it affects ALL Google login users)</li>
  <li>I have tried clearing the cache of Google Play services</li>
  <li>the Google API client is still connected</li>
  <li>I have tried updating all relevant google libraries to the most recent versions</li>
  <li>I see this on Android 6 - not sure if other versions are affected</li>
  </ul>
  
  <p>Before I post my code, I want to point out that the login never returns. The callback is never reached until I actively cancel the login (at which point it behaves as expected. I also want to emphasise again that my code has been in place for quite some time before this occurred - maybe something changed on Google side...</p>
  
  <p>I'm out of ideas and in dire need of help. Any ideas?</p>
  
  <h2>API client creation in <code>onCreate</code>:</h2>
  
  <pre><code>GoogleSignInOptions googleSignInOptions = googleSignInOptionsBuilder
          .build();
  
  googleApiClient = new GoogleApiClient.Builder(this)
          .enableAutoManage(this,
                  new GoogleApiClient.OnConnectionFailedListener() {
                      @Override
                      public void onConnectionFailed(
                              @NonNull ConnectionResult connectionResult) {
                          Logger.error("Google API connection failed");
                      }
                  })
          .addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)
          .addApi(Games.API)
          .build();
  </code></pre>
  
  <h2>Actual Sign-In method:</h2>
  
  <pre><code>public void signInWithGoogle() {
      logToServer("Google Sign-In Started");
      Intent signInIntent = Auth.GoogleSignInApi
              .getSignInIntent(googleApiClient);
      startActivityForResult(signInIntent,
              GameConstants.GOOGLE_REQUEST_CODE_SIGN_IN);
  }
  </code></pre>
  
  <h2>Callback (never touched)</h2>
  
  <pre><code>@Override
  protected void onActivityResult(final int requestCode, int response,
          Intent data) {
      super.onActivityResult(requestCode, response, data);
  
      if (requestCode == GameConstants.GOOGLE_REQUEST_CODE_SIGN_IN) {
          GoogleSignInResult result = Auth.GoogleSignInApi
                  .getSignInResultFromIntent(data);
          handleGoogleSignInResult(result);
      }
  }
  </code></pre>
  
  <p>...</p>