Android - “Connecting to Google Play” still gives Error Code 4?

穿精又带淫゛_ 提交于 2019-12-02 12:25:50
Daniil Andashev

If it connects and works fine in the local build, but the version you download from the Play Store doesn't work(it gives sign in error), this is how you fix it. When you uploaded your APK you used your SHA1 for the Uploaded Version. Google gives you a different SHA1 AFTER YOU UPLOAD YOUR APK. You need to input this NEW SHA1 into your Credentials.


Follow these steps:

  1. Go to Google Developer Console
  2. Click All Applications > Your Application
  3. Go to Release Management > App Signing
  4. Notice there is an "Upload Certificate" and an "App Signing Certificate".
  5. Copy the SHA1 from the APP SIGNING CERTIFICATE. (After all that keystore rigmorale, they fail to mention this part in documentation!)
  6. Create a new connected app in Game Services and then PASTE THE SHA1 FROM THE APP SIGNING CERTIFICATE HERE AND BE SURE YOUR PACKAGE NAME IS CORRECT.

Everything should work now! I don't understand why this is not documented clearly.

Make sure that you use the SHA1 key.

The command "keytool -list -keystore [path to debug keystore]" may display a SHA-256 key.

To get your SHA1 key you can follow these steps:

  1. Open your project
  2. Click on "Gradle" (on the right side)
  3. Choose your module
  4. Tasks -> android -> (double click) signingReport

image: get your SHA1 key

Sounds like your game may not be setup correctly in the play game console. Some things to check:

  1. The appId in your application matches the app id in the console.

  2. There is a linked Android application to your game.

  3. The linked application has the package configured to match the package in your AndroidManifest.xml
  4. The linked application is authorized and has the SHA1 fingerprint that matches the keystore you are using to sign your application.
  5. Make sure the user id you are using to sign-in is in the testers list for your game.
  6. If you are using SavedGamesAPI, make sure it is enabled on the console.

You can review the instructions to do all these things at https://developers.google.com/games/services/android/quickstart#step_2_set_up_the_game_in_the_dev_console

Fixed.

After getting countless SIGN_IN_REQUIRED I managed to allocate a lot of RESULT_APP_MISCONFIGURED.

The solution? It's very important to add a ProGuard exception, as described here.

DaleB

Even though it's four years since the original question was asked, I'd like to add my 2c worth as I had the same problem and none of the above advice solved it for me.

What solved it for me was realising that you need an SHA1 fingerprint for your app when it has been released into the Google Play Store and a different one for when you are debugging. The first is created automatically when you set up your app in the Google Play Console and is unique but it's never used until you release your app. The debug one you have to create yourself and it's the same for all the apps you are debugging. Details of the credentials are stored in your Google API Console.

To sum up, every app you have that uses Google Play Services should have two OAuth Client IDs in the Google API Console one for debug and one for the released version. How to so this is explained adequately in the documentation here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!