Google Play Services - Games

Hi folks,

Has anyone got this working with MonoGame? There doesn’t seem to be a lot of discussion about it so I can only assume that no-one is embedding hi-scores / achievements in their games.

I downloaded the Xamarin component that contains a sample project called BeGenerous and eventually got that working on a game service I setup on the Play developer console. I got that from the following link:

Xamarin Google Play Services - Games

I copied the packages and connection code from this project into my MonoGame project but the sign-in doesn’t work properly (takes a few attempts to connect and doesn’t display the popups).

Any help would be really appreciated, starting to lose patience now :frowning: I’m using MonoGame 3.4 with Xamarin 4.2 in Visual Studio.

Cheers,
Ronny

Have got this working a bit better now. I spotted the following line in adb logcat which occurs when I call StartResolutionForResult to resolve the initial SIGN_IN_REQUIRED connection failure:

W/ActivityManager( 1022): Activity is launching as a new task, so cancelling activity result.

Looks like the problem was being caused by the LaunchMode setting on my MainActivity:

LaunchMode=Android.Content.PM.LaunchMode.SingleInstance

Removing this results in MainActivity::OnActivityResult receiving an OK resultCode instead of Canceled.

Interesting. Thanks for reporting the fix. We will look into if that launch mode can be removed in the template.

The issue also seems to be device / API specific. It was happening on my Moto G with Android 4.4.4 (KitKat API 19) but not on my Nexus 7 with Android 5.1.1 (Lollipop API 22).

The Moto also fails to show popups (sign in & achievement unlocks), whereas the Nexus works fine.

Hello,

Did you manage to fix the missing popups in Moto G ? I’m having the same problem with a 4.4 samsung galaxy tab.

I’ve removed the LaunchMode and AlwaysRetainTaskState of the default template.

The weird thing is that if I perform a “Rebuild all”, the login popup appears once, but not anymore afterwards.

I’m not entirely sure but I think Google Play Games stores a login session which will timeout after a certain period (hrs / days) and is invalidated when you manually sign out. If a valid session exists when you make a call to login then the welcome popup never gets displayed.

If you could somehow clear the session on startup before kicking off the login process then that would force a proper login but I don’t know how to do that, or if it’s even possible. I just learned to live with it really, it would be nice to see the welcome popup every time but so long as it does actually login and work properly, I’m happy :wink:

I am getting ready to publish my game on Android and implementing Google Play Services with Xamarin.
I have couple questions for Leaderboards implementation.

My goal is to implement both Achievements and Leaderboards in-game, without the Google overlay.
I upload a score to leaderboard and when I try to load the leaderboard scores with “await GamesClass.Leaderboards.LoadTopScoresAsync”, in the response I get Status about reconnect required. If I try to load scores of a leaderboard where I haven’t uploaded a score I get Status = OK with no scores, as expected.

Even if I try to show the leaderboard with a score through the built-in overlay intent, the overlay shows up for a second and goes away.
If I try to show overlay for empty leaderboard the empty leaderboard shows up and stays there until I manually go back.

Automatic Signing-in, unlocking and reading Achievements is working properly.

Achievements and Leaderboards are created in Developer Console and it says Ready For Testing but nothing has been published so far.

I appreciate any help, tip or link that I can use to finalize the implementation!

I managed to solve this so let me share it with you, someone might find it useful.
Basically nothing worked properly, some parts just seemed they are working.
I tried everything. I added debug key credentials for testing in debug mode but that didn’t change anything.
All I had to do is to re-link the app :slight_smile:
I just went to developer console, created new linked app and everything was working fine!
Just make sure you set the new linked app as the default one or delete the first one so you don’t run into issues.

Raining Blobs is now available as demo and paid versions on the Play Store.
Big thanks to the MonoGame team for this wonderful framework!

Hello everyone and thank you for this post,

I’ve used Google Play Services to handle achievements and leaderboards in my game, and thanks to this post I managed to do it quickly.

I just want to add a few more information: I’ve been able to use the Xamarin NuGet package (Xamarin.GooglePlayServices.Games v.42.1021.1) in addition with MonoGame v3.6, but I needed to update the Android target version to Android 7.0 (API 24).

Here is a working example provided by Xamarin and specifically made for achievements and leaderboard.

Please note that if you use AppVeyor to make your Android build, you need to manually update Android SDK. Here is the script that I use, and here how to use it.

It’s not as easy as it sounds to make it works as expected, especially for this story about debug keystore, and I planned to write an article to explain the process in detail, I will do it for sure as soon as I have some time.

1 Like

Just for curiosity’s sake, have you calculated how much space all the DLLs from GPS-Games take in your APK?

I’ve been using it for months and I’ve never known if I’m doing something wrong or it just takes that insane amount of space.

For me, the final APK size changed from 20,1 Mo to 30 Mo just adding GPS-Games, and yes it’s a lot!

Fortunatly, when I upload it to Google Play, some optimizations are made and the final size is roughly 16 Mo, what remains acceptable.

I’ve updated my project’s Android target version from 7.0 to 8.0 to be able to update Xamarin NuGet packages related to GPS-Games, and it makes a real difference about APK size. Now, the same APK goes down to 24 Mo! :slight_smile:

Hi! Could you help me in how to sign in with google play games services? Xamarin doesn’t seem well documented and I’m struggling with it. What I’m trying to do is to check the Java API and try do use the same code, with fixes on Xamarin to work, but without success as some functions are different and I can’t put this to work. Thanks in advance,

Best Regards,
Eduardo