This page describes how to troubleshoot issues that you might encounter while developing Android games with Google Play Games Services.
Logging
To troubleshoot problems with your game, you can turn on verbose logging
on your device using the adb shell
command. You can then view the
Google Play Games Services log messages using logcat.
Enable logging
To enable logging on your test device:
Connect the device to a machine that has the Android SDK installed.
Open a terminal and run this command:
adb shell setprop log.tag.Games VERBOSE
Run your game on the device and reproduce the problem you are trying to debug.
View logs:
adb logcat
Disable logging
To disable verbose logging for the Play Games Services on your device and revert to the original logging behavior, run the following command:
adb shell setprop log.tag.Games INFO
Unable to sign in
If you are unable to sign players into your game, first make sure that you have followed the instructions to create your client IDs and configure games services. If you still encounter sign-in errors, check the following items to make sure that your game is set up correctly.
Check your metadata tags
Your AndroidManifest.xml
must contain a games metadata tag. To verify that
your metadata tags are correctly set up:
Open your
AndroidManifest.xml
and verify that it contains ameta-data
tag as shown below:<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />
Locate the definition of your
@string/app_id
resource. It is usually defined in an XML file located in theres/xml
directory, for exampleres/xml/strings.xml
orres/xml/ids.xml
.Verify that the value of the
@string/app_id
resource matches your application's numeric ID. The value of this resource should only contain digits. For example:<string name="app_id">123456789012</string>
Check your package name
Your game's package name must match the package name on your client ID. To verify the package name:
Open your
AndroidManifest.xml
and verify that your game's package name is correct. The package name is the value of thepackage
attribute in themanifest
tag.Verify the package name you supplied when creating your client ID. To verify the package name in Google Play Console, go to the Play Console and click on the entry corresponding to your game.
Go to the Linked Apps tab and examine the list of client IDs. There should be an Android linked app in this list whose package name matches the package name in your
AndroidManifest.xml
. If there is a mismatch, create a new client ID with the correct package name and try to sign in again.
Check the certificate fingerprint
The certificate with which you are signing your game should match the certificate fingerprint associated to your client ID. To verify this, first check your certificate's SHA1 fingerprint as follows:
Find your certificate file and obtain its SHA1 fingerprint. To obtain the SHA1 fingerprint, run this command:
keytool -exportcert -alias your-key-name -keystore /path/to/your/keystore/file -list -v
Take note of the sequence of hexadecimal digits labeled
SHA1:
in the output. That is your certificate's fingerprint.
Next, check that your build tool is using this certificate:
- Generate your game's APK from your build tool and sign it with the desired certificate. Copy the generated APK to a temporary directory.
In the temporary directory, run the following command to unzip your APK.
unzip YourGame.apk
Generate a private key using an RSA certificate file:
keytool -printcert -file META-INF/CERT.RSA
Alternatively, you can generate the private key using a DSA certificate file:
keytool -printcert -file META-INF/CERT.DSA
Note the sequence of hexadecimal digits on the line labeled
SHA1:
.This sequence of digits should match your certificate fingerprint from the previous step. If there is a mismatch, your build tool or system is not configured to sign your application with your certificate. In this case, consult your build environment's documentation to determine how to configure it correctly and try to sign in again.
Next, check if the certificate fingerprint matches the fingerprint configured in your client ID. To do this:
- Open the Play Console and navigate to your game.
- On the Game Details page, scroll to the bottom and click the link to the linked Google Cloud Platform project.
- Select your project.
- In the sidebar on the left, select APIs & auth. Make sure that the Google Play games services API status is ON in the displayed list of APIs.
- In the sidebar on the left, select Registered apps.
- Expand the OAuth 2.0 Client ID section and note the certificate fingerprint (SHA1).
If this fingerprint does not match your certificate's fingerprint from the previous steps, you must create a new client ID with the correct certificate fingerprint. You must create the new client ID in the Play Console, not in the Google Cloud Platform project.
Check that test accounts are enabled
Before a game is published, the account that created the game in the Play Console must also be enabled as a tester. To check that this is correctly configured:
- Open the Play Console and navigate to your game.
- Open the Testing tab.
- Check that the account you are trying to sign in with is in the list of testers.
If the account you are trying to sign in with is not listed, add it to the list, wait a few minutes and try to sign in again.
Proguard issues
If you are using Proguard and are seeing errors on the obfuscated APK, check the target API level
on your AndroidManifest.xml
. Make sure to set it to 17 or above.
Other causes of setup issues
Check for other common causes of errors:
- If your game is published, check that the game settings are also published (it is possible to publish the application without publishing the games settings). To do this, go to Google Play Console and navigate to your app, and check that the box next to the game's name indicates that it's published. If indicates that it is in another state, such as "Ready to Publish" or "Ready to Test", click the box and select Publish Game.
- If you can't publish your game, check that exactly one of the client IDs has the This app is preferred for new installations option enabled.
Anonymous listeners
Do not use anonymous listeners. Anonymous listeners are implementations of a listener interface that are defined inline, as illustrated below.
ImageManager im = ...;
// Anonymous listener -- dangerous:
im.loadImage(new ImageManager.OnImageLoadedListener() {
@Override
public void onImageLoaded(Uri uri, Drawable drawable) {
// ...code...
}
}
Anonymous listeners are unreliable because the Play Games SDK maintains them as weak references,
which means that they might be reclaimed by the garbage collector before they are
invoked. Instead, you should implement the listener using a persistent object
such as the
Activity
.
public class MyActivity extends Activity
implements ImageManager.OnImageLoadedListener {
private void loadOurImages() {
ImageManager im = ...;
im.loadImage(this);
}
@Override
public void onImageLoaded(Uri uri, Drawable drawable) {
// ...code...
}
}