While developing an Android app with Google Play Game Services integration a developer needs the following for testing Game Services features:
1. Ability to test in a Android debug app (signed with debug certificate) with unpublished achievements using a tester account.
2. Ability to test in a Android release app (signed with release certification), fully signed by Google Play with a published Game Services configuration.
Google provides some documentation on how to setup Game Services for Android. This documentation clearly outlines the configuration process:
However, despite these guides some developers might face some stumbling blocks along the way. After dealing with this myself, I’ve outlined below some general guidelines on how accomplish the configuration for both Android debug and release apps published to Google Play.
Testing in Debug Mode
To test in debug mode, you need to create a Linked App inside the Game Services configuration that corresponds to your Android debug app. The Client ID used by this Linked App needs to use the SHA1 fingerprint of the Android debug keystore (debug.keystore). Typically, for Windows users this keystore is located in the following path:
C:\Users\{your Windows username}\.android\debug.keystore
To find the fingerprint of this keystore all you need to do is run the following in the command prompt:
keytool -list -v -keystore "C:\Users\{your Windows username}\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
This command will spit out the SHA1 fingerprint of the certificate:
Certificate chain length: 1
Certificate[1]:
Owner: C=US, O=Android, CN=Android Debug
Issuer: C=US, O=Android, CN=Android Debug
Serial number: 1
Valid from: Thu Jul 07 15:17:58 EDT 2016 until: Sat Jun 30 15:17:58 EDT 2046
Certificate fingerprints:
SHA1: [SHA1 fingerprint]
SHA256: [SHA256 fingerprint]
Signature algorithm name: SHA1withRSA
Subject Public Key Algorithm: 1024-bit RSA key
Version: 1
You can then copy paste the SHA1 fingerprint into the SHA1 fingerprint of the Client ID needed by Game Services and you should be good to go.
If for some reason you can’t find the keystore there’s another way to find out the SHA1 fingerprint based on the Android app’s generated apk. The Android SDK Build Tools come with a nice little tool called “apksigner” that can be accessed through the command line via the following path
C:\Users\{your Windows username}\AppData\Local\Android\sdk\build-tools\{version}
The “apksigner” tool takes the path of an apk and returns information about the certificate that the apk was signed with. Below is an example of the command line:
apksigner verify --print-certs C:\{Your apk path}\app-debug.apk
This will spit out the SHA256, SHA1 and MD5 fingerprints of the keystore the apk was signed with:
Signer #1 certificate DN: C=US, O=Android, CN=Android Debug
Signer #1 certificate SHA-256 digest: [SHA-256 fingerprint]
Signer #1 certificate SHA-1 digest: [SHA-1 fingerprint]
Signer #1 certificate MD5 digest: [MD5 fingerprint]
Testing in Release Mode
The above instructions also apply for Release Mode, but with one small change: You need to use the SHA1 fingerprint of the certificate that Google Play uses to sign the release apk with in Google Play (called the “App signing certificate”, NOT the certificate you use to bundle your apk in release mode (called the “Upload Certificate”) from the “Build -> Generate Signed Bundle / APK” option in Android Studio.
Getting the SHA1 fingerprint of the App signing certificate is very simple. Go to Google Play Console, click on your app and navigate to the “Release Management -> App signing” section. In the “App signing certificate” section (screenshot below), use the SHA1 certificate fingerprint (masked in the screenshot below) for your release app Client ID.
The important thing here is to use SHA-1 fingerprint of the App signing certificate, NOT the Upload certificate.
In a nutshell, here’s the overall approach:
- Testing Game Services for debug Android: Create a Linked App using using a Client ID using the SHA1 fingerprint of Android’s default debug keystore (debug.keystore).
- Testing Game Services for release Android app in the Play Store: Create a Linked App using a Client ID using the SHA1 fingerprint of the “App signing certificate”.
I would say how long I’ve been hung up on this, but it would be too embarrassing. Google should hire you as a tech writer.