playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.46k stars 965 forks source link

Error code 16 with sign in attempt #2981

Closed FunnerSoft closed 3 years ago

FunnerSoft commented 3 years ago

Hello,

I am trying to integrate GPGS into my game project. This is an all new setup, and so it seems very likely that I am missing something. I have read many threads, docs, trouble shooting pages, etc. Nothing seems to be matching my setup and issue.

Here is what I have so far:

1) I have successfully built a .aab from Unity and uploaded it to the Google Play Console. 2) I have been able to download that same .aab from a test account that is associated with the Internal Test.

Note that no Game Play Services features were setup or used up to this point.

3) I configured Game Play Services from within the Google Play Console by following the guides / wizards. 4) I setup this Unity plugin within my game. 5) I built a new .aab from Unity that attempts to activate and sign in to Game Play Services.

I am trying to test this .aab build from Unity on my test phone (with the same test account mentioned above), and am getting sign in failures.

I believe Game Play Services is activating correctly, but it's the sign in that fails.

This is the code I am using.

PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
    .Build();
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();

PlayGamesPlatform.Instance.Authenticate(
    SignInInteractivity.CanPromptAlways,
    this.OnAuthenticateResults
);

This is the log snippet I get from Android Logcat

2020/12/17 08:27:47.019 29108 29144 Info Unity [Play Games Plugin 0.10.12] 12/17/20 8:27:44 -08:00 DEBUG: Creating new PlayGamesPlatform 2020/12/17 08:27:47.019 29108 29144 Info Unity System.Action:Invoke() 2020/12/17 08:27:47.019 29108 29144 Info Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() 2020/12/17 08:27:47.019 29108 29144 Info Unity
2020/12/17 08:27:47.019 29108 29144 Info Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35) 2020/12/17 08:27:47.019 29108 29144 Info Unity 2020/12/17 08:27:47.019 29108 29144 Info Unity [Play Games Plugin 0.10.12] 12/17/20 8:27:47 -08:00 DEBUG: Activating PlayGamesPlatform. 2020/12/17 08:27:47.019 29108 29144 Info Unity System.Action:Invoke() 2020/12/17 08:27:47.019 29108 29144 Info Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() 2020/12/17 08:27:47.019 29108 29144 Info Unity
2020/12/17 08:27:47.019 29108 29144 Info Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35) 2020/12/17 08:27:47.019 29108 29144 Info Unity 2020/12/17 08:27:47.020 29108 29144 Info Unity [Play Games Plugin 0.10.12] 12/17/20 8:27:47 -08:00 DEBUG: PlayGamesPlatform activated: GooglePlayGames.PlayGamesPlatform 2020/12/17 08:27:47.020 29108 29144 Info Unity System.Action:Invoke() 2020/12/17 08:27:47.020 29108 29144 Info Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() 2020/12/17 08:27:47.020 29108 29144 Info Unity
2020/12/17 08:27:47.020 29108 29144 Info Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35) 2020/12/17 08:27:47.020 29108 29144 Info Unity 2020/12/17 08:27:47.021 29108 29144 Info Unity [Play Games Plugin 0.10.12] 12/17/20 8:27:47 -08:00 DEBUG: Creating platform-specific Play Games client. 2020/12/17 08:27:47.021 29108 29144 Info Unity System.Action:Invoke() 2020/12/17 08:27:47.021 29108 29144 Info Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() 2020/12/17 08:27:47.021 29108 29144 Info Unity
2020/12/17 08:27:47.021 29108 29144 Info Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35) 2020/12/17 08:27:47.021 29108 29144 Info Unity 2020/12/17 08:27:47.021 29108 29144 Info Unity [Play Games Plugin 0.10.12] 12/17/20 8:27:47 -08:00 DEBUG: Creating Android IPlayGamesClient Client 2020/12/17 08:27:47.021 29108 29144 Info Unity System.Action:Invoke() 2020/12/17 08:27:47.021 29108 29144 Info Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() 2020/12/17 08:27:47.021 29108 29144 Info Unity
2020/12/17 08:27:47.021 29108 29144 Info Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35) 2020/12/17 08:27:47.021 29108 29144 Info Unity 2020/12/17 08:27:47.025 29108 29144 Debug HelperFragment Creating fragment 2020/12/17 08:27:47.027 29108 29108 Debug HelperFragment onResume called 2020/12/17 08:27:47.027 29108 29108 Debug SignInRequest signIn 2020/12/17 08:27:47.028 29108 29108 Debug SignInRequest Building client for: [removed] (a:false e:false i:false wc: f: false) 2020/12/17 08:27:47.044 29108 29108 Debug SignInRequest canReuseAccount: true 2020/12/17 08:27:47.048 29108 29108 Debug SignInRequest lastSignedInAccount is null 2020/12/17 08:27:47.049 29108 29108 Debug SignInRequest signInClient.silentSignIn 2020/12/17 08:27:47.303 29108 29108 Debug SignInRequest silentSignIn.onFailure 2020/12/17 08:27:47.343 29108 29144 Debug PlayerBase::stop() from IPlayer 2020/12/17 08:27:47.343 29108 29144 Debug AudioTrack stop() called with 235584 frames delivered 2020/12/17 08:27:47.369 29108 29108 Warn ActivityThread handleWindowVisibility: no activity for token android.os.BinderProxy@44ec974 2020/12/17 08:27:47.414 29108 29136 Info OpenGLRenderer Initialized EGL, version 1.4 2020/12/17 08:27:47.414 29108 29136 Debug OpenGLRenderer Swap behavior 2 2020/12/17 08:27:52.629 29108 29108 Error SignInRequest Setting result error status code to: 16 2020/12/17 08:27:52.643 29108 29108 Info Unity Returning an error code.

As for what I see when I run the app:

The title boots up. The Google Play Games logo pops up at the top of the screen. It expands into a white, elongated oval with no text. Collapses. And then nothing else happens. No request popups, no mention of my account name or info. Nothing.

Any help would be greatly appreciated. Thank you for your time. Les

FunnerSoft commented 3 years ago

Hello,

I found out some more info. It turns out that if I upload that same build to my Google Play Console then sign in works.

I don't know why that is though. Shouldn't my Unity builds properly sign in without uploading them?

I have been reading more about the SHA1 stuff. I made my keystore within Unity, and I chose the option for Google to manage my various keys. I am not sure if something is messed up there or not.

Do I have to upload a build to the Google Play Console before I can properly test things like cloud save, achievements, etc?

Thanks Les

djmuhlestein commented 3 years ago

Is it the case that your local builds have a particular signing key, and then your uploaded builds have a google managed signing key.. and that your GPG credentials are set up to use the latter google managed signing key?

FunnerSoft commented 3 years ago

Hi djmuhlestein,

Thank you for the response.

Yes, I believe that is the case.

After lots of reading, it seems like it's an issue with my keystore that I created through the Unity editor. The SHA-1 fingerprint in that keystore is different then what the Google Play Console shows (Google Play Console -> App -> Setup -> App Signing).

I tried copying the certificate(s) from the Google Play Console and importing them into my keystore. That didn't fix anything.

Les

jordyjordy commented 3 years ago

A bit late but in case someone has this issue in the future. Yes, you use a key to authenticate your app to google, and then google uses another key for the apps it ships through the appstore. This basically means that (illegal) copies of your app that are not distributed through the app store cannot access these services. They have a page about it here: https://developer.android.com/studio/publish/app-signing

FunnerSoft commented 3 years ago

Hi jordyjordy,

Thank you for the response. I appreciate it.

Everything you said and shared makes sense. But, is there no faster way to test?

Must I do the following every time I need to test my Google Play Games Services code?

1) Write the code 2) Make a Unity build 3) Upload the build to Google Console 4) Roll out to testers via console 5) Download update on test device 6) Test the code

Thank you again for sharing your info

jordyjordy commented 3 years ago

Hey FunnerSoft,

In the Google API's & Services where you have to set up a OAuth 2.0 Client ID which is linked to your app, you have to input the SHA1 of the key that is used to sign your app.

Here I inputed the SHA1 of my own upload key, rather than that of googles signed key. While im still developing this allowed me to directly test rather than uploading through google. However if your app is also live then this would disable your live application since they key won't match up I think.

So that is the "quick solution" i use while testing.

Im not sure, but i assume it MIGHT be possible to have two credentials active there, allowing you to link two signed keys at the same time, in case you really want both signed apps to work. (I have not tested this yet personally)

I hope this helps

FunnerSoft commented 3 years ago

Hi jordyjordy,

Ah, yes. I see how your idea might work. That's interesting.

This would also mean that I could properly debug Google Play Games Service code through Unity builds. Right? I would still have to build from Unity and run on device, but I could connect and debug I think? Currently, I can only test and "debug" by sifting through logs in LogCat.

I guess the only real question is if it's ok to have 2 credentials. It would have to be something like:

1) Google Cloud Platform -> API & Services -> Credentials -> Create Credentials -> OAuth Client ID -> (insert proper info for testing) 2) Google Play Console -> Play Games Services -> Configuration -> Add Credential

There are a few parts that concern me though ....

During step 2 there is a "Use for new installs" checkbox. It will warn you with "Another credential is being used for new installs. If you choose to use this credential, it will be used instead.". I am not exactly sure what this is all about.

Also, I seem to remember reading various warnings in the documentation that I should not create the OAuth Client ID in the Google Cloud Platform on my own. Rather that the wizard from within Google Play Console will direct me through the proper flow.

Do you have any insight into these parts?

Thank you again for the assistance

djmuhlestein commented 3 years ago

I can confirm It's OK to have 2 OAuth keys in GPGS settings. I've done that as well. Add the production one and add your development one. I can access the play games services with my development build as well as the released app.

I marked the production OAuth credential as the one with the "use for new installs". I don't know exactly how that works or if it matters though.

As far as the way the OAuth key is created, I think that information is outdated. I couldn't find a way in the new play games console to create an OAuth key at all other than if there was any key automatically created when you create the project or something.

FunnerSoft commented 3 years ago

Hi djmuhlestein,

Thank you for that information and the confirmation that I am barking up the right tree.

I also found this note "You may want to create two credentials: one with the release certificate fingerprint, and one with the debug certificate fingerprint. Make sure to use the same package name for both. This allows Google Play Games Services to recognize calls from your linked APKs that are signed with either certificate." in this doc (https://developers.google.com/games/services/console/enabling).

I am going to get this setup. It should greatly increase the iteration time.

Thank you to you both for the help with this. I have spent a LOT of time trying to figure this out. I really appreciate it.

FunnerSoft commented 3 years ago

For anyone coming across this in the future.

I can confirm that having 2 OAuth clients. One with your google-controlled signing key, and one with your Unity-controlled upload key. Will let you test Google Play Games Services code properly. And you will still be able to publish updates properly through Google Play Console.