1. Are you ready for the Galaxy S20? Here is everything we know so far!

Infinite Loop in Google Login

Discussion in 'Android Development' started by Wollo77, Jul 17, 2017.

  1. Wollo77

    Wollo77 Lurker
    Thread Starter

    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.

    • internet connectivity is ok
    • this happens to many users (not sure if it affects ALL Google login users)
    • I have tried clearing the cache of Google Play services
    • the Google API client is still connected
    • I have tried updating all relevant google libraries to the most recent versions
    • I see this on Android 6 - not sure if other versions are affected
    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...

    I'm out of ideas and in dire need of help. Any ideas?

    API client creation in onCreate:
    Code (Text):
    1. GoogleSignInOptions googleSignInOptions = googleSignInOptionsBuilder
    2.        .build();
    4. googleApiClient = new GoogleApiClient.Builder(this)
    5.        .enableAutoManage(this,
    6.                new GoogleApiClient.OnConnectionFailedListener() {
    7.                    @Override
    8.                    public void onConnectionFailed(
    9.                            @NonNull ConnectionResult connectionResult) {
    10.                        Logger.error("Google API connection failed");
    11.                    }
    12.                })
    13.        .addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)
    14.        .addApi(Games.API)
    15.        .build();
    Actual Sign-In method:
    Code (Text):
    1. public void signInWithGoogle() {
    2.    logToServer("Google Sign-In Started");
    3.    Intent signInIntent = Auth.GoogleSignInApi
    4.            .getSignInIntent(googleApiClient);
    5.    startActivityForResult(signInIntent,
    6.            GameConstants.GOOGLE_REQUEST_CODE_SIGN_IN);
    7. }
    Callback (never touched)
    Code (Text):
    1. @Override
    2. protected void onActivityResult(final int requestCode, int response,
    3.        Intent data) {
    4.    super.onActivityResult(requestCode, response, data);
    6.    if (requestCode == GameConstants.GOOGLE_REQUEST_CODE_SIGN_IN) {
    7.        GoogleSignInResult result = Auth.GoogleSignInApi
    8.                .getSignInResultFromIntent(data);
    9.        handleGoogleSignInResult(result);
    10.    }
    11. }

    1. Download the Forums for Android™ app!


  2. Deleted User

    Deleted User Guest

  3. Deleted User

    Deleted User Guest

    Another thing to check is the error log. Anything unusual reported there?
  4. Wollo77

    Wollo77 Lurker
    Thread Starter

  5. Wollo77

    Wollo77 Lurker
    Thread Starter

    I checked, but it's not giving any errors. I have not checked for debug output from outside the app (i.e. google play services), that may be worth a try.
  6. Deleted User

    Deleted User Guest

    Lol! That'll teach me to read questions properly.

    Another avenue to explore would be to trace the Google login Activity. Code should be available to set breakpoints in, and try to figure out what it's doing.

Share This Page