简体   繁体   中英

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:

  • I've configured correctly the Developer console side. The SHA1 is correct (matches the androiddebug keystore).
  • In the API Console everything looks fine.
  • I've extended GameBaseActivity and implemented requested interfaces.
  • I have an ids.xml in values folder which matches the one in the Developer Console.
  • I have overriden requested methods, included onActivityResult()
  • The manifest is also OK, it includes the requested metadata.

  • This is the code I use to sign-in in onCreate:

     setSignInMessages("SIGNING IN", "SIGNING OUT"); beginUserInitiatedSignIn(); 

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:

  • I also tried unwrapping BaseGameActivity and implementing GameHelper directly in my main Activity.
  • I tried publishing app games settings (because this game is already published on Play Store). Linked another app with my publishing signing SHA1 key. Setted as main app for installation. Still no luck.

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)?

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!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM