Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
520 views
in Technique[技术] by (71.8m points)

android - Google game services sign in issue (fails first attempt, successful second)

Currently trying to connect my game (that uses libgdx) to Google Game Services to enable leaderboard/achievements etc and seeing some strange behaviour.

Problem

When I first tap on "Sign in", it displays the dialog to choose your google account, then play services permission circles dialog, then the big loading circle. After a while, it displays a dialog with the following error Unknown issue with Google Play services

If I tap 'Ok' to dismiss that error dialog, then tap on the "Sign in" button again, I immediately get successfully logged in. After this, I can see the leaderboard etc.

Details

The error logs I'm seeing:

...
D: GameHelper: onActivityResult: req=RC_RESOLVE, resp=9001
D: GameHelper: onAR: responseCode=9001, so giving up.
D: GameHelper: killConnections: killing connections.
D: GameHelper: killConnections: all clients disconnected.
D: GameHelper: State change CONNECTING -> DISCONNECTED
D: GameHelper: Making error dialog for failure: SignInFailureReason(serviceErrorCode:SIGN_IN_REQUIRED(4),activityResultCode:9001)
D: GameHelper: Showing error dialog.
D: GameHelper: Notifying LISTENER of sign-in FAILURE (error)
I: ----- Sign in failed :( -----
///// Tap the 'sign in' button again ///////
I: ----- Begin sign in process... -----
D: GameHelper: Starting USER-INITIATED sign-in flow.
D: GameHelper: isGooglePlayServicesAvailable returned 0
D: GameHelper: beginUserInitiatedSignIn: starting new sign-in flow.
D: GameHelper: Starting connections.
D: GameHelper: State change DISCONNECTED -> CONNECTING
D: GameHelper: connectNextClient: requested clients: 1, connected clients: 0
D: GameHelper: Pending clients: 1
D: GameHelper: Connecting GamesClient.
D: GameHelper: onConnected: connected! client=1
D: GameHelper: Connected clients updated to: 1
D: GameHelper: connectNextClient: requested clients: 1, connected clients: 1
D: GameHelper: Pending clients: 0
D: GameHelper: All clients now connected. Sign-in successful!
D: GameHelper: All requested clients connected. Sign-in succeeded!
D: GameHelper: State change CONNECTING -> CONNECTED
D: GameHelper: Notifying LISTENER of sign-in SUCCESS
I: ----- Sign in success! -----
D: GameHelper: onActivityResult: req=3, resp=3
D: GameHelper: onActivityResult: request code not meant for us. Ignoring.
...

Since I'm using libgdx, I'm not extending BaseGameActivity instead, I'm creating a GameHelper manually and using that instead

// in @Override onCreate:
mGameHelper = new GameHelper(this);                
mGameHelper.setup(this, GameHelper.CLIENT_GAMES);    
mGamesClient = mGameHelper.getGamesClient();       

// in @Override onStart:
mGameHelper.onStart(this);

// then, for the sign in button, using it:
mGameHelper.beginUserInitiatedSignIn();

Extra info

I'm also seeing the following in the logs:

E: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

However, not sure if it is related, as from what I've read, this seems to be related to map/gps/location. Not using maps and I am able to log in, so not sure if this error is relevant or not (though it does sound quite bad!)

Update/Edit: After testing, this error was caused by AdMob (which I've integrated with the google services). Though the error sounds bad, disabling AdMob (no more error) the strange behaviour is still the same.

I think the below is the interesting error log, though haven't had much luck googling this error:

E/dalvikvm( 2618): Could not find class 'android.app.AppOpsManager', referenced from method axo.a

EDIT 2: More findings!
I get the same error dialog even if I don't go through the entire sign in workflow.

  • Tap 'Sign in'
  • See list of accounts to log in to
  • Tap 'Cancel'
  • See alert dialog with the title/message: Unknown issue with Google Play services

Any help will be great!

Note:

  • This can be consistently reproduced - log out, and two taps on the log in button gives the behaviour as described above
  • Made sure I am calling onActivityResult as suggested in Google Play Game Services: strange sign in behavior
  • Went through the tutorial and set up the sample app (Type A Number) - and everything worked.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Figured it out! It ended up being a stupid mistake!

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // mGameHelper.onActivityResult(requestCode, requestCode, data); // before - broken
    mGameHelper.onActivityResult(requestCode, resultCode, data); // after - working! o/
}

See the difference? (hint: second parameter of mGameHelper.onActivityResult)

For the benefit of others hitting this in the future, the following logs, though may indicate other errors, do not appear to affect the log in process - or game services in general - my leaderboard is working :)

E/GooglePlayServicesUtil(10033): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
From my debugging, this has to do with using AdMob and Google Play services. Chances are AdMob is attempting to get location based info (all other Google searches for the above error leads to Maps related questions)

E/dalvikvm(10100): Could not find class 'android.app.AppOpsManager', referenced from method axp.a
Not sure what this error is. android.app.AppOpsManager appears to be an class added in API v19 (AppOpsManager in Android Developer). I changed my SDK to use API v19, but still get this error. Quick skim of docs indicate it also has location related functionality (possibly AdMob again - don't think I saw this when I disabled AdMob)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...