Android setup
In this section of the tutorial we will go over the process of creating an app on the google playstore console step by step.
Creating a new android app
To create an app and game-id for google play you'll have to sign up for a developer account here.
After you have signed up, in the applist page click the blue button called "Create app". Select your app default language and give your app a name. For the sake of this tutorial we'll call it 'SP Social app'.
As you can see when you go back to the apps list your new app will be added to the list!
Building your game
After creating you app in the google console, you'll have to build and your app, and get the SHA1 fingerprint from it.
**NOTE** Make sure you build your game as an
Android App Bunde
For this tutotial I'll assume you know how to do this, but if not. Here is a tutorial, Signing android apps with Unity
Creating a new game
After creating the app in the dashboard and uploading, navigate to the section called Services and API's in the menu on the left side of the page.
Once located scroll down on the page where you'll find a big blue button called "Use google play services with this app".
Click that! You'll be send to a new page called "Gameservices".
On the Gameservices page you'll find a button at the top called Add new game. Give your game a name as requested, and choose a category that fits your game best.
For the sake of this tutorial we'll call it 'CP Social game'.
When you go back to the page gameservices, you'll see that your new game has been added to the list.
After creating you game you'll be navigated to a page called "Gamedetails". This is where you can find your game-id, it can be found as a large number just below the name of your app.
Once you have found your game-id, copy it into the "Android Game Id" field in the configurator of your unity project;
You'll notice that the blue links below it will change to "To android applist" and "To android game services". You can use these links to directly navigate to the applist & gameservices page, straight from your Unity project!
Linking your app to your game
To be able to access gameservices from your app you'll have to link your app you created you created first to your just created game.
Uploading your game
To upload your game:
- navigate back to the applist page
- Select your app
- Select App-releases (from the left navigation menu)
- Scroll all the way down to "Internal Test"
- Click on the button "Manage"
- Click on "Create release"
You might be promted with the question about 'Let google manage your signing keys' if so, select the "advanced" dropdown and select the third option, this will prompt you with a short tutorial on how to upload your siging keys (keystore generated by Unity) to google.
Once you have uploaded your signing keys to google, it's time to upload your build! To do this, just drag your ".aab" file into upload box.
If you get an error when trying to upload your build please take a look at the troubleshooting help at the bottom of this page.
After uploading your build, click save at the bottom om the page. after saving click the button next to save, check.
You might get an error saying you need to add a release discription. If so, click previous and add your release notes to the text box at the bottom of the page.
Linking
After uploading your build navigate back to the game services page, and select your game.
To link your app to your game navigate to the "Linked apps" section in the navigation menu on the left of the page, just below "Gamedetails".
On this page select Android.
.
Once you selected android you'll be send to a new page. On this page
- Enter the name of your game (this is what the players will see).
- Select you package name
.
After this, click save and continue.
Authorizing your app
Remember the SHA1 fingerprint you got from your keystore? This is where you need it.
Copy the SHA1 fingerprint from your console and past it into the inputfield shown.
.
Enabling Google game services in Unity
To enable Google game services in your unity project:
- Open your unity project
- Navigate to the menu Item Stan's Assets -> Android -> Services
- Click on Google play
- Click on the Off toggle, and set it to On
.
Setting game resources in Unity
After enabling google play in Unity through Stan's Assets, you have to add your Google game services resources.
These resources can be found on the "Achievements" (after you have added an achievement) tab on the Google game services page. On this page click on the blue link called Get resources.
The resources will look something like this:
Copy the android XML format to your clip board.
In Unity navigate to the Google play tab of Stan's Assets and click on "Set Game Resources"
This will open up a new window where you can paste the just copied Android resources.
After pasting the resources, click the save button, you'll see a popup "game-ids.xml saved"
Unity Jar Resolver
If you don't have any plugin in unity yet that includes the "Unity Jar Resolver", go back to the "Android native" tab of Stan's assets and click the "settings" button.
After navigating to the settings tab, click on the "Download" button, below "Unity Jar Resolver (EDM4U)"
This will start downloading all needed dependencies of you project, and will also make sure your android dependencies will be kept up to date.
That's it
Well done, you're now ready to use all the Google game services features from CP Social!!!
Next steps
Troubleshooting
Not the right uploadcertificate
Are you sure you are uploading a build, that has been build using the same keystore and keystore alias as you have uploaded for this app to google?
32 bit error
Google has the requirement that all apps uploaded are in a 64bit format. Make sure your unity project settings scripting backend is set to IL2CPP. More info here
APK no testers added
To fix this:
- Go back to the app-releases page
- Create a new list of tester
- Click the checkmark of the list to add them
- Click save
- Go back to the app-releases page
- Navigate to the internal test track
- Click on manage release
- Click again on Check
- Continue with this tutorial
APK not optimized
Google is moving to new Android app bundles which are a different type of file. Unity does support this, look here for more info on how to build an Android App bundle.