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:

 
Last edited:

Computersmith64

Well-Known 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.
 
Upvote 0

Greg Breinholt

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.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
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:
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User

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
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 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
Cookies are required to use this site. You must accept them to continue using the site. Learn more…