Angelo Tricarico
Angelo Tricarico

Reputation: 1363

BaseGameUtils Unknown Error, onConnectionFailed: result 4

I've already tested ButtonClicker 2000 example and it works great. Now I'm trying to implement Google Games Services into another game but it gives some error:

06-06 12:30:46.353: D/BaseGameActivity(7982): isGooglePlayServicesAvailable returned 0
06-06 12:30:46.353: D/BaseGameActivity(7982): beginUserInitiatedSignIn: starting new sign-in flow.
06-06 12:30:46.416: D/BaseGameActivity(7982): Connecting GamesClient.
06-06 12:30:46.424: D/BaseGameActivity(7982): onStart.
06-06 12:30:46.424: D/BaseGameActivity(7982): onStart: connecting clients.
06-06 12:30:46.424: D/BaseGameActivity(7982): Connecting GamesClient.
06-06 12:30:46.424: E/GmsClient(7982): Calling connect() while still connected, missing disconnect().
06-06 12:30:46.713: D/BaseGameActivity(7982): onConnectionFailed: result 4
06-06 12:30:46.713: D/BaseGameActivity(7982): onConnectionFailed: since user initiated sign-in, trying to resolve problem.
06-06 12:30:46.713: D/BaseGameActivity(7982): resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41692200: android.os.BinderProxy@416921a0}}
06-06 12:30:46.713: D/BaseGameActivity(7982): result has resolution. Starting it.

06-06 12:30:46.900: D/BaseGameActivity(7982): onActivityResult, req 9001 response 0
06-06 12:30:46.900: D/BaseGameActivity(7982): responseCode != RESULT_OK, so not reconnecting.
06-06 12:30:46.900: D/BaseGameActivity(7982): giveUp: giving up on connection. Status code: 4
06-06 12:30:46.900: D/BaseGameActivity(7982): Making error dialog for error: 4

com.google.android.gms logs the following error:

E/SignInActivity(7432): SignInActivity must be started with startActivityForResult

What I have done:

When testing the example Button Clicker 2000 I had the Unknown Error too and fixed it configuring the dashboard correctly. The current game dashboard is also configured correctly, so I don't really know what's happening. What am I missing?

EDIT:

Upvotes: 10

Views: 3039

Answers (4)

Yaadm
Yaadm

Reputation: 94

Problem:

ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{#: android.os.BinderProxy@#}}

solved by:

@Override
public void onConnectionFailed(ConnectionResult arg0) {
    <Your Code...>

    try {
        arg0.startResolutionForResult(this, 9001);
    } catch (SendIntentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

This is just a rough demonstration, handle the ConnectionResult as google suggest.

for more information Click Here

Upvotes: 0

user2161301
user2161301

Reputation: 834

according to your errors you are connecting the gamehelper twice (maybe in your oncreate?) and it returns error state 4. You don't give code but I am sure I know what's your problem. You are maybe messing up the google sign in with the GamesClient.connect Wait for the google account getting signed in before connecting the gamesclient. I did

public void onSignInSucceeded() {    
            mGamesClient.connect();}

You can create the GamesClient object in your onCreate, but the connect is better placed in this method I gave you. I spent hours with this problem, I hope I could help

Upvotes: 0

groug
groug

Reputation: 86

That's really strange. The error you've got, depending on your BaseGameActivity logs shouldn't happen.

SignInActivity is indeed not visible in the code, since you start it by calling GameHelper.resolveConnectionResult which will call mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE). That's mConnectionResult that has the Intent that will launch SignInActivity. And BaseGameActivity's logs are saying that you're starting it properly, so except if you've made some changes in BaseGameActivity and GameHelper, the error is strange.

Where are you looking for the errors? In your package filter? Really useful info are displayed in LogCat, but are not in your application filter. Look for all the messages with no filter, in LogCat, and search for the tags Volley and GameAgent. It may show you some errors.

One more thing: is the SignIn dialog showing nonetheless? When is the SignInActivity error is displayed (timestamp)?

Upvotes: 1

thiagolr
thiagolr

Reputation: 7027

The error is very clear:

E/SignInActivity(): SignInActivity must be started with startActivityForResult

This means that SignInActivity is being started with startActivity instead of startActivityForResult.

Search where this activity is being started and change to startActivityForResult. If you posted some code I would be able to help more!

Upvotes: 0

Related Questions