Signing Into Android Google Play Game Services with Unity

Google Play Game Services

Google Play’s Game Services provide mobile apps with social game elements like leaderboards, achievements, and quests, which can give more value to the players of those apps. Since I’m using Unity for my current project,  I’m using an asset called Android Native Plugin from Stan’s Assets (ANP). Personally, I am not sure of how many other asset solutions there are that do the same thing, but at the time that I needed it, this asset was pretty much staring me in the face with its high number of customer reviews at pretty much 5 stars, its reasonable price, and the many testimonials mentioning the great support. So I went with it.

I actually used ANP first on Number Crunchers, for banner ads on the menu screens, and I also had some luck with Game Services login on that app, but decided against fully implementing the solution at that time.

Signing In

While Stan’s Assets and the Google Play online documentation are quite thorough in describing how to set up game services, the natural progression in software development is that shit happens, and not all the answers to your problems are immediately available. There have been some ongoing discussions on the Unity forums regarding connection issues, and here are some potential solutions and suggestions that I read about there to get this working, in no particular order.

  • The first thing suggested to me was to go to Edit > Project Settings > Quality Settings, and to set V Sync Count to either “Every V Blank” or “Don’t Sync”. Apparently some users have run into issues if this is set to “Every Second V Blank”.
  • The documentation for ANP still mentions that you can test on an emulator (not sure if this is still true), but it’s almost always a good idea to use an actual device to test on. Deploying admittedly takes a long time, but at least the results are far more accurate. The Google Play documentation also mentions using a debug certificate, and linking a debug version of the game in the Developer Console, but when I tested this, I did not get this to work, so you’ll have to deploy a signed APK.
  • Another suggestion was to delete the entry for the game in Game Services in the Developer Console, and then re-enter it, with a new keystore and client certificate. It sounds like a bit of work to redo, but it could possibly be the culprit.
  • If by chance, you’re upgrading from a previous version of the asset, first, back up your project. I was upgrading from 6.3 to 6.8, and I failed to fully read the “Update Best Practices” page, which probably would have saved me some headaches. Instead, I hand-picked all the files and folders to delete from my Unity project Assets folder, and installed a fresh copy of ANP. This resulted in a broken asset similar to what user D0R1N encountered here. I tried wiping the files clean again, and got as far as publishing and deploying my APK file, but I was still unable to connect. It was only until I again removed ANP using the “Remove” button inside the plugin that I got the asset working correctly.
  • Lastly, there have been suggestions (starting from user petediddy) about using a coroutine to wait for the connect() call to finish. In any of your Monobehaviours, particularly on init,
    void Start()
        StartCoroutine ("StartGooglePlay");
    IEnumerator StartGooglePlay()
        if (GooglePlayConnection.state != GPConnectionState.STATE_CONNECTED)
            GooglePlayConnection.instance.connect ();
            yield return new WaitForSeconds (1f); //pause for 1 second

    This isn’t directly tied to disconnection problems, but it has been mentioned for those who have had problems with sign-in latency and delays. I decided to keep this solution around in my code until a more stable release or workaround has been established.

I can’t guarantee that these solutions will work for everyone, but it’s what I gathered from the thread. I’m sure I missed a few other gotchas for the setup process, and am willing to add them here if anyone gives me a ping about it. There are quite a few landmines that can get you into trouble, so be careful ;).

Good luck!


  • Unity 5.1.3p2
  • Android Native Plugin 6.8.1
This entry was posted in Dev, Programming. Bookmark the permalink.

2 Responses to Signing Into Android Google Play Game Services with Unity

  1. zyndro says:

    Hey Man thanks for the heads up !

    I’m having the same issue with no luck.. i was wondering if you could specify the wait co routine you used on the connect() call ?

    Thank you !

Leave a Reply

Your email address will not be published. Required fields are marked *