8

There is an app that uses play games service, but by some reason it stops working. it looks some times i can login successfully but usually - no. if i checked API traffic there is about 10% got response code = 200, and others - 404.

methods that get 404:

  • games.applications.played
  • games.events.record

when i tried to check error in log i see:

11705-13707/com.google.android.gms W/GamesServiceBroker: Client connected with SDK 12171000, Services 11975436, and Games 54390036
11705-9262/com.google.android.gms E/BoundService: No such BoundService for action: com.google.android.gms.auth.APP_CERT
11705-9262/com.google.android.gms E/BoundService: No such BoundService for action: com.google.android.gms.auth.APP_CERT
691-778/system_process E/PROXIMITY: ProximitySensor: unknown event (type=3, code=0)
8876-8890/com.agminstruments.drumpadmachine V/FA: Inactivity, disconnecting from the service
691-778/system_process E/PROXIMITY: ProximitySensor: unknown event (type=3, code=0)
2254-2269/? I/PerfService: PerfServiceNative_getPackName
11705-16860/com.google.android.gms E/Volley: [3966] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/games/v1/players/me?language=ru-RU
11705-9262/com.google.android.gms E/PlayerAgent: Unable to load player g08394879143000804289
11705-9262/com.google.android.gms W/PlayerAgent: {"errors":[{"domain":"global","reason":"invalid","message":"Invalid applicationId with value . Reason: No application ids specified."}],"code":400}
3978-3978/com.google.android.play.games.ui I/SignInActivity: Transition from 8 to 11
3978-3978/com.google.android.play.games.ui W/SignInActivity: onSignInFailed()...
3978-3978/com.google.android.play.games.ui W/SignInActivity: Sign in failed during 8
3978-3978/com.google.android.play.games.ui W/SignInActivity: ==> Returning non-OK result: 10002

i not understand why there is no ID in the message "Invalid applicationId with value ." because i've added id into the application. also i've tried to change the ID, and in this case i got an error that ID XXXXXXXXXXXX not linked with app my.package.name.

also i've double checked Application ID, SHA fingerprints , re-import google-services.json also tried to add manually OAuth2 Client ID from linked apps. check play services instruction and everything looks ok. what more i can check?

Update:

tried to update play-servies to 11.8.0 and use GoogleSignInClient

 mGoogleSignInClient = GoogleSignIn.getClient(application, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
 activity.startActivityForResult(mGoogleSignInClient.getSignInIntent(), 312);

but also got an error:

com.google.android.gms.common.api.ApiException: 4: 
Siarhei
  • 2,358
  • 3
  • 27
  • 63
  • just try this copy/paste the "App signing certificate" "SHA-1 certificate fingerprint" - Instead of the "Upload certificate" "SHA-1 certificate fingerprint" which is the one from your keystore, inside the API ID client OAuth 2.0 . hope this helps – PN10 Mar 06 '18 at 12:30

4 Answers4

1

I also had the "com.google.android.gms.common.api.ApiException: 4" on a device. Updating the Google Play Games app solved this problem for me.

Then I just had to manually click the Google Sign in button in my app. I hope this helps!

using gms_library_version '11.8.0' and the code I'm using:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //...
    mGoogleSignInClient = GoogleSignIn.getClient(this, new GoogleSignInOptions
            .Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build());
    //...
 }



// when the button gets clicked
public void startSignInIntent() {
    startActivityForResult(mGoogleSignInClient.getSignInIntent(), RC_SIGN_IN);
}


    @Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (requestCode == RC_SIGN_IN) {

        Task<GoogleSignInAccount> task =
                GoogleSignIn.getSignedInAccountFromIntent(intent);

        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            onConnected(account);
        } catch (ApiException apiException) {
            String message = apiException.getMessage();
            if (message == null || message.isEmpty()) {
                message = getString(R.string.signin_other_error);
            }

            onDisconnected();

            new AlertDialog.Builder(this)
                    .setMessage(message)
                    .setNeutralButton(android.R.string.ok, null)
                    .show();
        }
    }

    //...
  }
Daniel Metzner
  • 101
  • 2
  • 4
1

Clearing cache and data is also one of the major solutions of this errors.

1.Go to Setting >> Go to Application Setting (In some devices application setting is named as apps). 2.Go to, All the apps > >Find the Google Play Store >> Clear Data and Cache 3.Once you have clear everything, Next you need to Force Stop the application. Also, Find Google Services Framework >> Open Google Services Framework >> Clear cache and data Now, Restart your device and try to download the app.

1

as described here. error code 4 means

public static final int SIGN_IN_REQUIRED

The client attempted to connect to the service but the user is not signed in. The client may choose to continue without using the API. Alternately, if hasResolution() returns true the client may call startResolutionForResult(Activity, int) to prompt the user to sign in. After the sign in activity returns with RESULT_OK further attempts should succeed.

Constant Value: 4

so Make sure SHA-1 signing-certificate fingerprint of your app in google developers console belong to the same key which is used to sign APK you are testing.

when assembling debug build Android Studio use own debug key. You can change it from

right-clicking on the app folder in Project dir -> selecting "Open Module Settings"-> "Signing" tab -> configure the same key you have mentioned in google dev console. After that navigate to the "Build Types" tab and select your signing configuration.

OR

checkout this answer too.

Omkar
  • 3,040
  • 1
  • 22
  • 42
0

Try this, Firstly start with Debugging Play services,

  • Enable Debug play services in code > make apk > install on device > open "Monitor" from "tools" folder in android sdk > connect device to PC > run

  • After Debugging, if you got this message

"You have wrong OAUth2 related configurations, please check. Detailed error; UNREGISTERED_ON_API_CONSOLE" "OnSignInFailed()..."

  • Go to

enter image description here

Just copy/paste the "App signing certificate" "SHA-1 certificate fingerprint" - Instead of the "Upload certificate" "SHA-1 certificate fingerprint" which is the one from your keystore, inside the API ID client OAuth 2.0 .

This will do your work!!

As of now, google play games is no more connecting in local. But it's connecting successfully when it's been imported into the google play store (Google App signing does exactly what it's supposed to do: it changes your SHA1 from the "upload certificate" one to the "App signing" one).

Note: Above image is taken from one of GitHub open issue. Hope this helps!!

PN10
  • 1,888
  • 3
  • 23
  • 34
  • Hello, thank you. i haven't found how to Enable Debug play services in code in 11.8.0. Certificate not uploaded currently, but it worked before. it looks like it stops working when OAuth 2.0 client IDs had been changed. btw, is it ok that app id in google cloud and game services console is different? so, there is a different OAuth2 Client ID. – Siarhei Mar 07 '18 at 23:56
  • I've added certificate to console and fingerprints to firebase but got the same error :( – Siarhei Mar 08 '18 at 20:04
  • @user5599807 No u r getting it wrong...will try to clarify your doubts tomorrow...sry I can't help right now...I hv some deadlines to catch up... – PN10 Mar 08 '18 at 20:19
  • Hello, @PN10 , please help, i still have an issue. – Siarhei Mar 12 '18 at 17:17
  • @user5599807 have you enabled tester account in google play console?Also are u working with unity plugin? If not, Add tester email addresses to the testing section of your game on the Play Games Console. – PN10 Mar 12 '18 at 18:27
  • yes, i've enabled testers account and added account to Play Games Console as well. (not working with unity plugin, it is java application) – Siarhei Mar 13 '18 at 10:20
  • found that there was 2 google account on the device and by default used incorrect one. now it works. thank you – Siarhei Mar 13 '18 at 11:10
  • @user5599807 That's great !!Cheers!! – PN10 Mar 13 '18 at 11:44
  • i've set up google analytic to check login/failed. previously success was 15% users, after changes 60%. not sure what happens for other 40% users – Siarhei Mar 15 '18 at 14:12
  • @user5599807 About analytics this is not related to this problem if u are facing any issue create a separate question ...provide link here !!! – PN10 Mar 16 '18 at 09:08
  • i've checked statistic and looks it not working for all, but it is better that it was before, thank you :) i've created new question: https://stackoverflow.com/questions/49380292/google-games-login-works-for-50-users-only – Siarhei Mar 20 '18 at 09:23