Android Question Google Play Game Services library - issues with TurnBasedMultipPlayer [solved with workaround]

Greg Breinholt

Member
Licensed User
Longtime User
I've been (successfully) using this Library to use the Google Play leaderboard:

All worked fine, but suddenly getting the error below. Note that I am not actually using TurnbasedMultiplayer in my code.. but from what I can see, Google has killed this API:

Anyone have any ideas how to resolve this? Does it need an update to the Library removing all links to the removed API?

Greg

Edit: Workaround found Removing/replacing the asynchronous calls stops the crash. See the later comments.

Recommended to use this library:

1606826713749.png
 
Last edited:

Computersmith64

Well-Known Member
Licensed User
Longtime User
That's correct I am using this code:

B4X:
    'Loads the list of leaderboards  
    Leaderboards.LoadLeaderboardMetadata(True).SetResultEvent("GP_onLeaderboardsLoaded")

I was not aware that I'm using custom Leaderboard - I created one in the Play Console (image below).
Is this classed as custom?

View attachment 107221


Do you know if there an alternative way to create the Leaderboard or get the data from it that would prevent the error?

Oh - my mistake. You are using a standard leaderboard, but I'm not sure why you're calling LoadLeaderboardMetadata. If you want a list of leaderboards, you should call getAllLeaderboardsIntent - but if you only have 1 leaderboard then you should just call it directly with GetLeaderboardIntent("leaderboard_id").

- Colin.
 
Upvote 0

Greg Breinholt

Member
Licensed User
Longtime User
Oh - my mistake. You are using a standard leaderboard, but I'm not sure why you're calling LoadLeaderboardMetadata. If you want a list of leaderboards, you should call getAllLeaderboardsIntent - but if you only have 1 leaderboard then you should just call it directly with GetLeaderboardIntent("leaderboard_id").

- Colin.

OK... got it working - much appreciate your insights! ;-)

I stopped using the LoadLeaderboardMetadata (wasn't really using it, other than as a check that the leaderboard existed), and I was getting the data through the Leaderboard ID anyway. But I was getting then getting the same error on submitting a score. Changing the code as below removed the error:

B4X:
'Leaderboards.SubmitScoreImmediate(Leaderboard_Id, Percent).SetResultEvent("GP_onScoreSubmitted")
Leaderboards.SubmitScore(Leaderboard_Id, Percent)

I was using this code to show a toast when it was a submission was made and a new high score returned. But I think I can explore other ways to compare the users score with the current Leaderboard high score and provide them with appropriate feedback.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
OK... got it working - much appreciate your insights! ;-)

I stopped using the LoadLeaderboardMetadata (wasn't really using it, other than as a check that the leaderboard existed), and I was getting the data through the Leaderboard ID anyway. But I was getting then getting the same error on submitting a score. Changing the code as below removed the error:

B4X:
'Leaderboards.SubmitScoreImmediate(Leaderboard_Id, Percent).SetResultEvent("GP_onScoreSubmitted")
Leaderboards.SubmitScore(Leaderboard_Id, Percent)

I was using this code to show a toast when it was a submission was made and a new high score returned. But I think I can explore other ways to compare the users score with the current Leaderboard high score and provide them with appropriate feedback.
Yeah - I've never used the asynchronous submit functions. I find that the "fire & forget" submissions are generally 100% reliable.

- Colin.
 
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Longtime User
This isn't working for me because I am trying to load achievements.

B4X:
Achievements.Load(False).SetResultEvent("GP_onAchievementsLoaded")

Here is the error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/games/multiplayer/turnbased/TurnBasedMultiplayer$CancelMatchResult;
at flm.b4a.googleplay.PendingResultWrapper.SetResultCallback(PendingResultWrapper.java:579)
at flm.b4a.googleplay.PendingResultWrapper.SetResultEvent(PendingResultWrapper.java:738)
at mindware.minegames.starter._connection_success(starter.java:294)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
at mindware.minegames.clsconnection._gpc_onsigninsucceeded(clsconnection.java:518)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at flm.b4a.googleplay.GooglePlayConnection.SucceedSignIn(GooglePlayConnection.java:437)
at flm.b4a.googleplay.GooglePlayConnection.onConnected(GooglePlayConnection.java:422)
at com.google.android.gms.common.internal.zah.zaa(com.google.android.gms:play-services-base@@17.5.0:30)
at com.google.android.gms.common.api.internal.zaar.zaa(com.google.android.gms:play-services-base@@17.5.0:295)
at com.google.android.gms.common.api.internal.zaaf.zaf(com.google.android.gms:play-services-base@@17.5.0:130)
at com.google.android.gms.common.api.internal.zaaf.zaa(com.google.android.gms:play-services-base@@17.5.0:108)
at com.google.android.gms.common.api.internal.zaaz.onConnected(com.google.android.gms:play-services-base@@17.5.0:105)
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
This isn't working for me because I am trying to load achievements.

B4X:
Achievements.Load(False).SetResultEvent("GP_onAchievementsLoaded")

Here is the error:

Is there a specific reason you're trying to load achievements? I used to load them & then check to see which ones were locked before unlocking them, but I found this to be problematic, so I just execute an unlock regardless. If the achievement is already unlocked, then GPGS just ignores the request. If you're using incremental achievements this might not work though...

- Colin.
 
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Longtime User
I have a few things that the Achievements list is needed for.

I have a menu item where they can open their achievements. I update all achievements when they try to open their achievements.

Is there a way to update an achievement without having the Achievements variable initialized?
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I have a few things that the Achievements list is needed for.

I have a menu item where they can open their achievements. I update all achievements when they try to open their achievements.

Is there a way to update an achievement without having the Achievements variable initialized?
To show a player their achievements, I use:
B4X:
Private i As Intent = Achievements.GetAchievementsIntent
GPUtils.StartActivityForResult(i, ACHIEVEMENTS_DLG)
To unlock an achievement I use:
B4X:
Achievements.Unlock("achievement_id")

- Colin.
 
Last edited:
Upvote 0

Greg Breinholt

Member
Licensed User
Longtime User
I kind of wish that the Google Play Games Services library was one of the official internal libraries (same as the GooglePlayBilling)... since its core to use Google's Leaderboards & Achievements. But I accept that there's only so many libraries that Erel can support, and this might not be a priority.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I kind of wish that the Google Play Games Services library was one of the official internal libraries (same as the GooglePlayBilling)... since its core to use Google's Leaderboards & Achievements. But I accept that there's only so many libraries that Erel can support, and this might not be a priority.
I agree - & that's actually why I've ended up rewriting some of my apps in Kotlin. When you rely heavily on library wrappers (like I do for GPGS) & they get out of sync with newer versions of the Android APIs, it makes it very hard to keep existing apps working. Unfortunately I don't have the time (or expertise) to rewrite a wrapper as complex as the GPGS one.

- Colin.
 
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Longtime User
How about we see if Biswajit would update/rewrite the library (on contract to be paid)? I too wish it would be an official library, but it probably won't happen as this library is maybe not used by enough people.
 
Upvote 0

Greg Breinholt

Member
Licensed User
Longtime User
How about we see if Biswajit would update/rewrite the library (on contract to be paid)? I too wish it would be an official library, but it probably won't happen as this library is maybe not used by enough people.
I think user @Informatix created the original lib - he might be in a better position to update (though it was several years ago!)
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Again: The Library Informatix wrapped in the past is another library then the new Game Services Library.
The new one replaces the old one.

One need to write a completely new wrapper for the new Lib
I agree. It is better to use the new API than trying to tinker with my library because sooner or later the old API will be completely deprecated.
I consider my library to be a dead project and should no longer be used.
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
I have contracted with @Biswajit to re-write the library with the new API. I will authorize him to share with the community when it's ready.
Here is the new wrapper.
 
Upvote 0
Top