ERROR while show leaderboards
hdls19 opened this issue · 5 comments
Hi
First, thanks for the your work
I'm using your library in my game and getting an error when I call the gsClient.showLeaderboards() method
The code i am using in AndroidLauncher:
public class AndroidLauncher extends AndroidApplication {
private GpgsClient gpgsClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AsteroidBustersXGame game = new AsteroidBustersXGame();
this.gpgsClient = new GpgsClient()
.setGpgsLeaderboardIdMapper(new IGameServiceIdMapper<String>() {
@Override
public String mapToGsId(String independantId) {
return GpgsMappers.mapToGpgsLeaderboard(independantId);
}
})
.initialize(this, false);
game.gsClient = gpgsClient;
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useAccelerometer = false;
config.useCompass = false;
config.useImmersiveMode = true;
initialize(game, config);
}
}
Main Game Class create() method:
if (gsClient == null) {
Gdx.app.log("GS_CLIENT", "GsClient is null");
gsClient = new MockGameServiceClient(1) {
@Override
protected Array<ILeaderBoardEntry> getLeaderboardEntries() {
return null;
}
@Override
protected Array<String> getGameStates() {
return null;
}
@Override
protected byte[] getGameState() {
return new byte[0];
}
@Override
protected Array<IAchievement> getAchievements() {
return null;
}
@Override
protected String getPlayerName() {
return null;
}
};
}
Gdx.app.log("GS_CLIENT", "GsClient set listener");
gsClient.setListener(this);
//My game initialization
Gdx.app.log("GS_CLIENT", "GsClient resume session");
gsClient.resumeSession();
Where I call showLeaderboards() method:
highscoresButton = new ImageButton(highscoresStyle);
highscoresButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
try {
game.gsClient.showLeaderboards(LEADERBOARD1);
}
catch (GameServiceException e) {
Gdx.app.error("GS_CLIENT", "Failed to show leaderboards", e);
}
}
});
GpgsMappers class:
public class GpgsMappers {
public static String mapToGpgsLeaderboard(String leaderboardId) {
String gpgsId = null;
if (leaderboardId != null) {
if (leaderboardId.equals(AsteroidBustersXGame.LEADERBOARD1))
gpgsId = "CgkIjOjVy8gdEAIQAQ";
}
return gpgsId;
}
}
I also have a version of gdx 1.10.0, in the example its - 1.9.8. Most likely the problem is somewhere else.
Authorization passes - a welcome gpgs popup window appears with my username, but when click 'Highscores' it's load gpgs highscores page, but loading is freezing
Thanks in advance
You will get this error on every call. You need to do what the error tells you: link your app in the Play Games dev console.
Google Play Games is different to set up. https://developers.google.com/games/services/console/enabling
I found out what the reason was - in my console in Play Games Services > Setup and Management > Configuration was only 1 credentials for release. When add debug credentials - then everything worked