问题
This is very similar to a problem someone else had on here except that the solution that fixed theirs is not my problem. (Note: I am using libgdx to develop this but I'm pretty sure that has nothing to do with this issue since the signing part is working)
@Override
public void startQuickGame() {
boolean signedIn = getSignedIn();
System.out.println(signedIn);
// automatch criteria to invite 1 random automatch opponent.
// You can also specify more opponents (up to 3).
Bundle am = RoomConfig.createAutoMatchCriteria(1, 4, 0);
// build the room config:
RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
roomConfigBuilder.setAutoMatchCriteria(am);
RoomConfig roomConfig = roomConfigBuilder.build();
// create room:
aHelper.getGamesClient().createRoom(roomConfig);
}
And here is where I check when the room is created.
final static int RC_WAITING_ROOM = 10002;
@Override
public void onRoomCreated(int statusCode, Room room) {
if (statusCode != GamesClient.STATUS_OK) {
System.out.println(statusCode);
return;
}
// get waiting room intent
Intent i = aHelper.getGamesClient().getRealTimeWaitingRoomIntent(room, Integer.MAX_VALUE);
startActivityForResult(i, RC_WAITING_ROOM);
}
The status code I'm getting there is 6 which corresponds to
STATUS_NETWORK_ERROR_OPERATION_FAILED
I'm definitely signed in before it creates the room as signedIn is always true.
My package name is matching, and I'm even seeing this in my api console.
回答1:
Are you creating the room by Auto-Picking a name? Or by selecting someone in your circles?
I have not published my app in final release (several months of alpha/beta testing, and I'm close :) ), but when I create rooms that I have invited people that are NOT part of the testing group, I get Error 6 (and in fact I have created methods to handle that situation for the release version.. if that same error occurs when a user tries to create a room when released)
If the auto-pick works fine, and you have added the selected people into your testing emails, then the only time I've gotten error 6 would be when the network is having issues (whether on my end or Google's, not sure) but it has been very temporary in nature.
So, I would think ensuring that they are part of your testing group (and may even have to have installed the app, not sure on that part as I haven't tested that out... new test to add!), would be where I would start.
回答2:
Figured it out. Misleading Javadoc plus human error.
I took that second argument to mean the max number of players, not the max number of players to invite, hence you + 3 others.
So here is the culprit in my code =p
Bundle am = RoomConfig.createAutoMatchCriteria(1, 4, 0);
Should be
Bundle am = RoomConfig.createAutoMatchCriteria(1, 3, 0);
And now it works just fine =)
来源:https://stackoverflow.com/questions/18902457/google-play-services-sign-in-succeeded-but-error-on-create-room