[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Troubleshooting Play Games Services in Android games\n\nThis page describes how to troubleshoot issues that you might encounter while\ndeveloping Android games with Google Play Games Services.\n\nLogging\n-------\n\nTo troubleshoot problems with your game, you can turn on verbose logging\non your device using the `adb shell` command. You can then view the\nGoogle Play Games Services log messages using logcat.\n\n### Enable logging\n\nTo enable logging on your test device:\n\n1. Connect the device to a machine that has the Android SDK installed.\n\n2. Open a terminal and run this command:\n\n ```\n adb shell setprop log.tag.Games VERBOSE\n ```\n3. Run your game on the device and reproduce the problem you are trying to\n debug.\n\n4. View logs:\n\n ```\n adb logcat\n ```\n\n### Disable logging\n\nTo disable verbose logging for the Play Games Services on your device and\nrevert to the original logging behavior, run the following command: \n\n```\nadb shell setprop log.tag.Games INFO\n```\n\nUnable to sign in\n-----------------\n\nIf you are unable to sign players into your game, first make sure that you have\nfollowed the instructions to\n[create your client IDs](https://developers.google.com/games/services/console/enabling)\nand\n[configure games services](https://developers.google.com/games/services/console/configuring).\nIf you still encounter sign-in errors, check the following items to make sure\nthat your game is set up correctly.\n\n### Check your metadata tags\n\nYour `AndroidManifest.xml` must contain a games metadata tag. To verify that\nyour metadata tags are correctly set up:\n\n1. Open your `AndroidManifest.xml` and verify that it contains a `meta-data` tag as shown below:\n\n \u003cmeta-data android:name=\"com.google.android.gms.games.APP_ID\"\n android:value=\"@string/app_id\" /\u003e\n\n2. Locate the definition of your `@string/app_id` resource. It is usually defined in an XML file\n located in the `res/xml` directory, for example `res/xml/strings.xml` or `res/xml/ids.xml`.\n\n3. Verify that the value of the `@string/app_id` resource matches your application's numeric ID.\n The value of this resource should only contain digits. For example:\n\n \u003cstring name=\"app_id\"\u003e123456789012\u003c/string\u003e\n\n| **Warning:** Do not use the full client ID (`1233456789012.apps.googleusercontent.com`) as your app ID. This will result in errors.\n\n### Check your package name\n\nYour game's package name must match the package name on your client ID. To verify the package name:\n\n1. Open your `AndroidManifest.xml` and verify that your game's package name is correct. The package\n name is the value of the `package` attribute in the `manifest` tag.\n\n2. Verify the package name you supplied when creating your client ID. To verify\n the package name in Google Play Console, go to the\n Play Console and click on the entry corresponding to your game.\n\n3. Go to the **Linked Apps** tab and examine the list of client IDs. There\n should be an Android linked app in this list whose package name matches the\n package name in your `AndroidManifest.xml`. If there is a mismatch, create a new\n client ID with the correct package name and try to sign in again.\n\n### Check the certificate fingerprint\n\nThe certificate with which you are signing your game should match the\ncertificate fingerprint associated to your client ID. To verify this, first\ncheck your certificate's SHA1 fingerprint as follows:\n\n1. Find your certificate file and obtain its SHA1 fingerprint. To obtain the\n SHA1 fingerprint, run this command:\n\n keytool -exportcert -alias your-key-name -keystore /path/to/your/keystore/file -list -v\n\n2. Take note of the sequence of hexadecimal digits labeled `SHA1:` in the\n output. That is your certificate's fingerprint.\n\n| **Note:** If you are using a debug certificate, replace `your-key-name` with `androiddebugkey` in the command above. If using a release certificate, use the name you chose for your key when creating the certificate.\n\nNext, check that your build tool is using this certificate:\n\n1. Generate your game's APK from your build tool and sign it with the desired certificate. Copy the generated APK to a temporary directory.\n2. In the temporary directory, run the following command to unzip your APK.\n\n unzip YourGame.apk\n\n3. Generate a private key using an RSA certificate file:\n\n keytool -printcert -file META-INF/CERT.RSA\n\n Alternatively, you can generate the private key using a DSA certificate file: \n\n keytool -printcert -file META-INF/CERT.DSA\n\n4. Note the sequence of hexadecimal digits on the line labeled `SHA1:`.\n\n This sequence of digits should match your certificate fingerprint from the\n previous step. If there is a mismatch, your build tool or system is not\n configured to sign your application with your certificate. In this case,\n consult your build environment's documentation to determine how to configure\n it correctly and try to sign in again.\n\nNext, check if the certificate fingerprint matches the fingerprint configured\nin your client ID. To do this:\n\n1. Open the Play Console and navigate to your game.\n2. On the **Game Details** page, scroll to the bottom and click the link to the linked Google Cloud Platform project.\n3. Select your project.\n4. 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.\n5. In the sidebar on the left, select **Registered apps**.\n6. Expand the OAuth 2.0 Client ID section and note the certificate fingerprint (SHA1).\n\nIf this fingerprint does not match your certificate's fingerprint from the\nprevious steps, you must create a new client ID with the correct certificate\nfingerprint. You must create the new client ID in the\nPlay Console, not in the Google Cloud Platform project.\n| **Note:** If you are debugging your game using your debug certificate but have configured games services using your release certificate, you should add a second linked app using the same package name and your debug certificate's SHA1 fingerprint. This will allow you to sign in to the application whether it's signed with the debug or release certificates.\n\n### Check that test accounts are enabled\n\nBefore a game is published, the account that created the game in the\nPlay Console must also be enabled as a tester. To check that\nthis is correctly configured:\n\n1. Open the Play Console and navigate to your game.\n2. Open the **Testing** tab.\n3. Check that the account you are trying to sign in with is in the list of testers.\n\nIf the account you are trying to sign in with is not listed, add it to the list, wait a few minutes\nand try to sign in again.\n| **Warning:** The account that created the game in the Play Console does not automatically become a tester. If you wish to sign in to the game with that account, you must add it as a tester explicitly.\n\nProguard issues\n---------------\n\nIf you are using Proguard and are seeing errors on the obfuscated APK, check the target API level\non your `AndroidManifest.xml`. Make sure to set it to 17 or above.\n\nOther causes of setup issues\n----------------------------\n\nCheck for other common causes of errors:\n\n- 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**.\n- If you can't publish your game, check that exactly one of the client IDs has the **This app is\n preferred for new installations** option enabled.\n\nAnonymous listeners\n-------------------\n\nDo not use anonymous listeners. Anonymous listeners are implementations of a listener interface\nthat are defined inline, as illustrated below. \n\n ImageManager im = ...;\n\n // Anonymous listener -- dangerous:\n im.loadImage(new ImageManager.OnImageLoadedListener() {\n @Override\n public void onImageLoaded(Uri uri, Drawable drawable) {\n // ...code...\n }\n }\n\nAnonymous listeners are unreliable because the Play Games SDK maintains them as weak references,\nwhich means that they might be reclaimed by the garbage collector before they are\ninvoked. Instead, you should implement the listener using a persistent object\nsuch as the\n[`Activity`](https://developer.android.com/reference/android/app/Activity). \n\n public class MyActivity extends Activity\n implements ImageManager.OnImageLoadedListener {\n\n private void loadOurImages() {\n ImageManager im = ...;\n im.loadImage(this);\n }\n\n @Override\n public void onImageLoaded(Uri uri, Drawable drawable) {\n // ...code...\n }\n }"]]