Search code examples
androidgoogle-apigoogle-play-servicesgoogle-play-games

Android - "Connecting to Google Play" still gives Error Code 4?


I'm still a bit new to the Google APIs and the GoogleApiClient class, so I followed this tutorial hoping to get set up enough to display a leaderboard.

At the moment I've implemented this code into my game activity.

public void onConnectionFailed(ConnectionResult arg0) {
    Log.d("fes", "error " + arg0.getErrorCode());
    if (!isGooglePlayIntentOpen && arg0.hasResolution()) {
        try {
            isGooglePlayIntentOpen = true;
            startIntentSenderForResult(arg0.getResolution()
                    .getIntentSender(), 10, null, 0, 0, 0);
        } catch (SendIntentException ex) {
            isGooglePlayIntentOpen = false;
            this.getApiClient().connect();
        }
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 10) {
        isGooglePlayIntentOpen = false;
        if (!this.getApiClient().isConnecting() && !this.getApiClient().isConnected()) {
            this.getApiClient().connect();
        }
    }
}

This does, in fact, pop up a small intent that says "Connecting to Google Play", followed by a selection of an account. Which is as expected.

However, every time onConnectionFailed gets called, the error code appears to be 4.

According to ConnectionResult, 4 means Sign-in Required.

What gives? Even after attempting to "sign in" on multiple accounts, I still get the same error code. Do I somehow need to pass the sign-in result to my GoogleApiClient?

Cheers!


Solution

  • Fixed.

    After getting countless SIGN_IN_REQUIRED I managed to allocate a lot of RESULT_APP_MISCONFIGURED.

    The solution? It's very important to add a ProGuard exception, as described here.