In this article we will take you through setting up each component of the Google Play Services extension in your project and getting it to work inside your Android game.
Note that this is quite a long article and has several sections, so if you have an existing app you just want to add a new extension into, please use one of these links to jump to the bit you need. If you're creating a new game/app, please start at the start and work your way down, but feel free to skip any of the sections for the extensions you will not be using.
Contents
- Download The Google Play Services Demo
- Set Up Your Google Play Console
- Adding Testers To Your Apps
- Use The Google Play Services Extension In Your Games
- Add The Additional Functionality You Require
- Troubleshooting: Google Says Your Uploaded .aab Does Not Support 64bit
Download The Google Play Services Demo
For a comprehensive demo containing all the code required to make all the below services work, please see our Marketplace asset for Google Play Services.
First add the Google Play Services extension to your account from the marketplace.
Open your Marketplace library by going to Marketplace > My Library:
Then download the project and import everything:
Feel free to take a look at the project's contents, perhaps run/"create exe" it just to confirm your Android setup is working, but be aware nothing in the first room (everything Google Play Services) is going to work just yet.
Follow through this guide in order to get all the IDs and other values you need for configuring the demo to target your app, which then gets the demo working fully and shows you how to set up various Google products at the same time.
Set Up Your Google Play Console
Before you can test any Google Play Services functionality you first have to register for a Google Play account on the Google Play Console and then create yourself an app.
Once you are registered, click the big blue Create button at the top of your All Apps page.
Here, you will be asked to supply some initial information for the game and once you click the button at the bottom of the short form it will create the new app and place you on its Dashboard page.
For now, you can ignore the Start Testing Now section and instead work your way through each of the "questions" in Set up your app.
For each question, click on it, give the answer or complete the wizard it asks you to provide, click the Save button at the bottom of the page, then click the <- Dashboard link at the top of the page. You will then see that list shown above start being ticked off, showing which questions have been done and which still need doing.
We would strongly advise you pause reading this guide and instead take the time now to thoroughly set up all of your app metadata, icons, and other values, so you know you are actually ready to test it later on. (Note also that you will not be able to even see Google Play Services menu options until some of this is done.)
Adding Testers To Your Apps
Once you have set up your app listing, it's time to say who can test it.
Now, Google allows Internal, Closed, and Open testing tracks. However, we recommend for your own dev testing you should always use Internal, as the review times are very quick (typically your app is ready for download via the Play Store app within an hour or two) and the process of getting builds to your testers is more straightforward than the other tracks.
Closed and Open allow for more testers and more feedback facilities, but they are beyond the scope of this guide and so won't be show below. There is also a direct binary sharing facility, but again we usually stick to the Internal release track. Please see Google's own docs if you want to use any of these alternatives.
Create A Tester Mailing List
To begin working with the Internal test track system, if you have more people than just yourself who will need to test your apps and you have multiple apps you want to release, then we recommend making a mailing list so that you don't need to add everyone manually to every app.
First, go back to your account page, rather than this app's dashboard:
Then click on the Email lists entry under Settings
Click the blue Create email list button in the top-right of the page and then fill in a name for the list and all the required email addresses here. Ensure you click the save button at the bottom of the page once you're finished, then click the back arrow to go back to your Email lists page again.
Now, any time you create a new app/new release track for an app, you can just tick to use the email list, and then everyone on the list will be able to get your app from the Play Store.
Note, however, that these mailing lists are not used for denoting who can test IAPs or for who can log-in to Google Play Services inside your apps - those are handled on separate pages in your Console, and we will get to these later in the guide...
Create An Internal Release
To create an Internal test release, ensure you're on the correct app and then click the Create new release button shown on the Internal page. (Remember to also enable your Tester mailing list while you're here!)
Google will then ask you to confirm you want to use the newer managed signing system. Just click the blue Continue button to enable this. Then, further down on that page, upload an .aab file made inside GameMaker by clicking the Create Exe button and ensuring you choose an .aab output type. Add release notes as required, then click the Save button in the bottom corner. The page will refresh.
Click Review release button to confirm supported devices and languages are as expected, then click the Rollout button to actually start the release. As mentioned above, this will usually take somewhere around an hour or so to actually go live and then be available for your Testers to get it from the Play Store app on their phones/tablets.
How Do Your Testers Get Your App?
Before you even send testers the email/link, they need to have opted-in to receive developer builds within their Play Store app. They need to click on their profile pic, select Settings, expand the About section, and then tap the Play Store Version value 7 times (just like unlocking a phone for dev usage).
Then, once you have created your Internal release, go back to the Testers section and you can copy the link from here:
Send them that link, they open it on an Android phone/tablet using the Google Account they intend to test your app with and they click to accept being a tester for the app. At this point, your tester will be able to see this app in their Play Store app even though no-one else can see it yet. Note that if a tester has multiple devices they only need do this once and then they can just download the app as normal on any device using that same Google account.
Use The Google Play Services Extension In Your Games
Now that you have created an app, confirmed you can build something and release it to testers, and have set up some store metadata, you next need to say that this app will use Google Play Services (which the newer Google Play Console site now calls "Play Games Services" in some places, so be aware of this).
If you have followed all the above sections of this guide and so filled-in your store metadata and also published an Internal release already, then your Console will automatically expose the Play Games Services menu in the sidebar:
Note that this will menu not appear until you have rolled out at least one release!
This will then show you a screen where you have to say whether or not you have already created a Google Cloud project for this app to talk to - unless you already did this yourself before starting this guide, the answer here is "no".
Give a name for your Google Play Services project (it will default to the game's app name, so unless you really want to change it, just leave it as-is). Fill in the requested information and then press Continue.
You will now be taken to your app's Google Play services management page. You will see that you're now asked to set up your Oauth credentials - click the button to do this now, and in the little popup which appears, click the link to open a new browser tab containing the Google Cloud portal for this game.
Here, you pick whether this app will always be internal to your team/company, or if you intend releasing it to the public ("external"). Make this choice, then follow through the remaining forms. This guide assumes you chose External.
When you get to the Scopes screen, these choices are up to the needs of your game, so we won't go into much detail here, but if you ticked everything relevant to Google Play Services and didn't add any custom extras, then you would end up with something like this:
On the next screen, add your tester emails - ensure you click the blue Add button after typing the email addresses in and before you collapse the sidebar, otherwise the page will forget everything you typed! Click Save and Continue again when you're done adding testers.
Now you're on the review/summary screen and can just click Back to Dashboard.
Create Your Developer Keystore Credential
Now you're back on the Google Cloud dashboard for your game, click on Credentials in the menu on the left, then + Create Credentials at the top of the page. You will need an OAuth 2.0 type credential, but feel free to use the "Help Me Choose" wizard and follow through that - leave the Scopes as you set them up earlier and ensure you create this credential for Android.
When you get to the SHA-1 fingerprint and it asks you to run a keystore command, ignore this command and instead go back to GameMaker, open Preferences > Platform Settings > Android and the scroll down to the bottom of the window. Here, click the Show Key Hash button, then select everything in the SHA-1 field here and paste this key into the fingerprint field on the website. Double-check you copied everything correctly, then you can finish up the Credential process.
When you're returned to the Credentials main page, leave this browser tab and go back to the tab containing your Google Play Console and then refresh the page / click the refresh button where it says you have no credentials. You will now see that panel split into two boxes:
Click Add credential and then say it will be for Android, use the default value for your game name, enable/disable anti-piracy as you wish, then in the credentials dropdown below, pick the one we just set up on Google Cloud for this game. Click Save, then click to go back to the previous page again.
You should now see your Android credential in the box. This means you can build and test Google Play Services yourself...
Create Your Play Store Credential
However, you now need to go back to the Google Cloud browser tab and repeat everything you just did with + Add Credential, but this time giving the credential a different name and using the fingerprint for the SHA-1 certificate fingerprint value you get for your individual app's App signing key certificate (the second field down) on this page of your Play Console:
This will then allow your players to use Google Play Services in your released games. If you do not do this, all your developer testing will work fine, but none of your players will be able to sign in when they use released Production track versions.
Although you may well be nowhere near releasing your game yet, we would recommend that you do this step now, just so it can't be forgotten later...
Find Your Google Play Services ID
Once you have created both sets of credentials and linked both of them to your game, about midway down this Play Games services configuration page you will see your game's unique Project ID is shown.
Copy this value just now and paste it into GameMaker inside Game Options > Android's Google Services ID text field:
If for some reason you were not on the correct page to find that ID, it's this one:
Add Your Play Games Services Testers
Click on the Testers menu item under Play Game Services in the menu on the left.
On the Release Tracks tab, choose to add a track and pick the one we created earlier for the app.
On the Testers tab, you might find that your app testers list has been pulled in automatically, but this doesn't always happen in our testing. Regardless, add/remove people as you require just now. Note that there is a short delay after you type in each email before the address is accepted, and you can only click the Save button once all entries have been accepted.
Publish Your Play Games Services
Now that you have configured the Play Games Services section of your Console and assigned some testers, you can now review and ultimately publish your new social functionality.
Note that if you have not finished setting up your store metadata, then the Review page will insist you do so before you will be allowed to publish. Also be aware that once you enable Play Game Services you are unable to remove some fields from this app on your Console later on.
As the site says, it may take a few hours before your Play Services functionality will then work in-game. However, that should be all you need to do in order to get Google Play Services sign-in working, which is the first step toward integrating any of Google's products into your game.
Add The Additional Functionality You Require
With that, you now have a Google Console account, created your first Android app and published it to a list of testers, enabled Google Play Services and released this functionality to your testers also, and have learned how to distribute apps to your testers.
You also have a project which shows how to log in to Google Play Services and also shows how to implement various forms of test ads, and all of this should now be working for you and your testers (bar the Consent Form for ads, as you are yet to create your own IDs for this).
The demo already shows all the code required for cloud saving/loading and also to purchase and validate a couple of different types of in-app purchase products. We will go through this in a later guide, but now you know how to use your Google Play Console you're free to start experimenting with creating in-apps and modifying the code in the demo so you can test your own purchases whenever you want.
Similarly, the demo also shows all the code required to implement achievements and leaderboards, so we will look into these below...
Create A Leaderboard
On your Google Play Console, make sure you have selected the correct app you want to create a leaderboard for, then choose the Play Game Services menu option for Leaderboards:
This will open the landing page for leaderboards and on here you will see the large blue Create leaderboard button.
When you click that button you'll be taken to a new page where you must give the details for the leaderboard: giving it a name, a value type (score, currency or time) as well as supplying an icon and a few other things.
This short form is quick to fill in and pretty self-explanatory, so we won't document it all here. If you're at all unsure what a field means, hover over the little ? button next to its name and this will give you more advice.
One minor thing to note is if you supply a custom unit type, then you need to provide the localised words for this type. However, according to the format preview it will append directly onto the numeric value and there is no way to avoid this, so hopefully the store will fix it properly:
Once you're happy with the values you have added onto the form, click the Save as Draft button in the bottom-right corner.
Now, copy the ID for this leaderboard from the top of the page (your ID will be different, so you can ignore the one shown here):
Replace the leaderboard ID string in the __macros__ script with your own leaderboard ID to test it with the demo:
Once you have copied the ID into your code, you're free to click the back arrow to return to the Leaderboards dashboard.
If you want to create additional leaderboards you can do so (the demo allows you to test up to 2 leaderboards, for more you have to add your own code) but whenever you're done you can now click the Review and Publish button in the top-right or go to the actual Publishing page in the menu bar to the left to begin publishing your leaderboard(s).
IMPORTANT! While a leaderboard is not yet published you can freely edit its properties, but once it has been published for the first time you will not be able to edit anything.
As you can see, setting up leaderboards is a simple process and requires only a little time to get working. Once you have set up the Google Play Console metadata for your leaderboard you should be able to run the game from GameMaker on your device, log in, and then be able to post scores to the leaderboard. You can also press the Show Leaderboard button to open the Play Services leaderboards overlay and see how your score compares with other players'.
Create An Achievement
On your Google Play Console, make sure you have selected the correct app you want to create a leaderboard for, then choose the Play Game Services menu option for Achievements:
The same as we saw for leaderboards, this will open the landing page for achievements and on here you will see the large blue Create achievement button.
When you click that button you'll be taken to a new page where you must give the details for the achievement: giving it a name, description, whether or not it increments over multiple achievement posts, whether or not it is hidden until the player unlocks it, as well as supplying an icon and a few other things.
This short form is quick to fill in and pretty self-explanatory, so we won't document it all here. If you're at all unsure what a field means, hover over the little ? button next to its name and this will give you more advice.
Once you're happy with the values you have added onto the form, click the Save as Draft button in the bottom-right corner.
Now, copy the ID for this achievement from the top of the page (your ID will be different, so you can ignore the one shown here):
Replace the achievement ID string in the __macros__ script with your own achievement ID to test it with the demo:
(Note that each achievement in this demo works differently (incremental, hidden, locked), so make sure to read the comment above an achievement macro to ensure your replaced achievement matches.)
Once you have copied the ID into your code, you're free to click the back arrow to return to the Achievements dashboard.
If you want to create additional achievements you can do so now, and whenever you're done you can click the Review and Publish button in the top-right or go to the actual Publishing page in the menu bar to the left to begin publishing your achievement(s).
IMPORTANT! While an achievement is not yet published you can freely edit its properties, but once it has been published for the first time you will not be able to edit anything.
As you can see, setting up achievements is a simple process and requires only a little time to get working. Once you have set up the Google Play Console metadata for your achievement you should be able to run the game from GameMaker on your device, log in, and then be able to press the relevant button to unlock this achievement. You can also press the Show Achievements button to open the Play Services achievements overlay and see which ones you have unlocked.
Troubleshooting: Google Says Your Uploaded .aab Does Not Support 64bit
When you upload an .aab to the Internal track and then click to review the new release, you may see this error message:
This one simply means that you forgot to enable/accidentally disabled Arm64 architecture support in Game Options > Android > Architecture.
Click the back button on the page, so you can go back to the Create new internal release page, and there delete the .aab you just uploaded. Then, back inside GameMaker, click the box shown here:
Clean your project cache just to be safe, then create a new .aab and upload that one instead.