Skip to content

Commit

Permalink
Update documentation with troubleshooting
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Ibáñez Sánchez <jacobibanez@jacobibanez.com>
  • Loading branch information
Iakobs committed Jan 2, 2024
1 parent 92adb37 commit 8fe2f6c
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
74 changes: 73 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Godot 4.2+ plugin for integration of the latest version of [Google Play Game Ser
- [Kotlin Code](#kotlin-code)
- [GDScript Code](#gdscript-code)
- [Google](#google)
- [Troubleshooting](#troubleshooting)
- [Google Credentials](#google-credentials)
- [Contact me](#contact-me)

## Forewords
Expand Down Expand Up @@ -96,9 +98,79 @@ The main page for Game Services is [this one](https://developers.google.com/game

When it comes to Google Play Console, the main page is [here](https://developer.android.com/distribute/console), but the Google Play Game Services documentation also provides a good setup guide [here](https://developers.google.com/games/services/console/enabling).

## Troubleshooting
Here I will add common problems and possible solutions, if any. Thanks to all the people that have opened issues with their problems, so now we can help others in the future to avoid common pitfalls.

### Google Credentials
This is one of the major problems when testing and using the plugin. In order to properly use Google Play Games Services, you have to:
- Create your app of type `game` in your Google Play Console.
- Add and configure the Games Services in your Google Play Console.
- This involves creating your game assets such as achievements, leaderboards, etc
- This also, **AND MOST IMPORTANTLY**, includes adding credentials.
- Create the credentials in your Google Cloud and link them in your game in your Google Play Console.
- Make sure that you sign your `.aab` or `.apk` with the correct credentials (in Godot **AND** in the Play Store!)

Creating and linking credentials is a source of confusion, as the process includes many steps. Please refer to the [Google docs](https://developers.google.com/games/services/console/enabling#b_create_a_credential) for further information about creating credentials.

#### Identifying the problem

You will know that your app is failing due to authentication problems, because you will see a message like this in the `adb` logs:

```
**** APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES
**** DEVELOPER_ERROR
**** This is usually caused by one of these reasons:
**** (1) Your package name and certificate fingerprint do not match
**** the client ID you registered in Developer Console.
**** (2) Your App ID was incorrectly entered.
**** (3) Your game settings have not been published and you are
**** trying to log in with an account that is not listed as
**** a test account.
**** (4) A server auth code was requested, but an incorrect client
**** id was provided. The client id for server auth codes should
**** be the client id for the game server (not the android app).
****
**** To help you debug, here is the information about this app
**** Package name : your.package.name
**** Cert SHA1 fingerprint: AA:AA:11:AA:A1:11:11:11:11:A!:1A:AA:A1:11:1A:A1:1A:A1:11:1A
**** App ID from manifest : 111111111111
****
**** Check that the above information matches your setup in
**** Developer Console. Also, check that you're logging in with the
**** right account (it should be listed in the Testers section if
**** your project is not yet published).
****
**** For more information, refer to the troubleshooting guide:
**** http://developers.google.com/games/services/android/troubleshooting
****
```

> :warning: This error log can also appear if you have not properly configured the plugin to use your Game id, which is actually in the logs (App ID from manifest). Make sure you followed the [Configuring the plugin](#configuring-the-plugin) steps if you see this error in the logs.
#### Solving the problem

To solve this problem, you have to create an OAuth2 Android Client in your Google Cloud that matches the package name of your game **AND** the `SHA1` certificate of any keystore you are using to sign your app.

You can create as many credentials as you want, so usually my recommendation is to have three credentials:
- One credential for the debug keystore, to use while developing and testing the debug build variant.
- One credential for the release keystore, to use while testing the release build variant.
- One credential with the Play Store certificate, to use when you publish your app to the Play Store.

This is how it looks in Google Cloud (ignore the web auth client autogenerated by Google):
![Screenshot of a Google Cloud menu with three Android OAuth2 clients and an extra web client, not relevant here](docs/images/cloud_clients.png)

And this is how it looks in the Google Play Console:
![A screenshot of the Google Play Console menu of the app with three credentials created in the Play Games Services section](docs/images/console_credentials.png)

The one that causes more problems is the client with the Google Play Store credentials. The process to sign your app and publish it to the Play Store generates a new public certificate that you don't control, and this is the one that many people is missing, and the most important one. To be able to locate the `SHA1` of this certificate, you can see it in the `Release > Setup > App signing` section of your Play Console:

![Screenshot of the section in the Play Console](docs/images/play_store_sha1.png)

Creating the OAuth2 Client in your Google Cloud and linking it to a new credential in your App in your Google Play Console, will solve the problem, and you will be able to log in from your game.

## Contact me
If you have any questions or want to propose changes, features, or found a bug, please feel free to [open an issue](https://github.com/Iakobs/godot-play-game-services/issues/new).

I try to answer in the same day and provide all help I can, even if it's out of scope of the plugin, like guiding over some Google configurations, etc.
I try to answer in the same day and provide all the help I can, even if it's out of scope of the plugin, like guiding over some Google configurations, etc.

Please, be kind and respectful when creating issues.
Binary file added docs/images/cloud_clients.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/console_credentials.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/play_store_sha1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions plugin/demo/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ The demo project contains a `scenes` folder with all the `.tscn` and `.gd` files

You have sub folders for every feature of the plugin, e.g. `achievements` for displaying the achievements of the game or `snapshots` for the save/load game functionalities.

== Running the project
IMPORTANT: Make sure that you are using version 4.2+ of Godot. This plugin is only for version 4.2 or higher.

This is an android project with a custom build, so in order to run your game from the Godot editor, you have to install the build template first. Please, refer to the https://docs.godotengine.org/en/stable/tutorials/export/android_gradle_build.html[Godot docs] for further information.

You also have to create an `Export Configuration` for Android. Refer to the https://github.com/Iakobs/godot-play-game-services#export-configuration[README] of the repository.

Finally, you can not run the game as a normal game. Instead, you have to run it in an android device (real or emulated) via the `Remote Debug` button in the top right corner of the Godot editor.

== Signing In
The first thing the project does is checking if the user is authenticated, and if not, calls the `sign_in` method of the plugin.

Expand Down

0 comments on commit 8fe2f6c

Please sign in to comment.