Google Play Games plugin doesn't initialize

Hey folks,

I’ve been going through the process of integrating Google Sign-In into my game. I’m using the GitHub - playgameservices/play-games-plugin-for-unity: Google Play Games plugin for Unity plugin, and it appears something’s changed and it no longer works.

Previously my code was as follows to initialize the plugin:

PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().AddOauthScope( "profile" ).RequestIdToken().RequestServerAuthCode( false ).Build();
        PlayGamesPlatform.InitializeInstance( config );
        PlayGamesPlatform.Activate();

Now, however, the initialization is different and apparently not working for me.

PlayGamesPlatform.Instance.Authenticate( ( status ) =>
{
    // this callback is never hit
} );

Does anyone know why this wouldn’t even return with a failure but instead just hang?

Thanks!
-Matt

It’s possible it won’t hit in the editor… are you talking an in-editor-only problem? Or does it also fail to hit on device?

Usually for editor you #if-guard the entire block of sign-in code out… but perhaps that’s not required with this plugin.

No, I know better…sadly it’s happening on device, and I’m not sure why. I need this plugin to work, I don’t see how it can be live and not work (the problem is almost certainly something I did, but what?!)

Bust out your adb logcat and see if there’s any actionable noise in the log output.

Thanks for the suggestion, it appears the following error pops up trying to initialize the plugin:

AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
10-05 15:43:40.111 17091 17220 E Unity   : java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
10-05 15:43:40.111 17091 17220 E Unity   :      at java.lang.Class.classForName(Native Method)
10-05 15:43:40.111 17091 17220 E Unity   :      at java.lang.Class.forName(Class.java:454)
10-05 15:43:40.111 17091 17220 E Unity   :      at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
10-05 15:43:40.111 17091 17220 E Unity   :      at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
10-05 15:43:40.111 17091 17220 E Unity   :      at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
10-05 15:43:40.111 17091 17220 E Unity   :      at android.os.Handler.dispatchMessage(Handler.java:102)
10-05 15:43:40.111 17091 17220 E Unity   :      at android.os.Looper.loopOnce(Looper.java:226)
10-05 15:43:40.111 17091 17220 E Unity   :      at android.os.Looper.loop(Looper.java:313)
10-05 15:43:40.111 17091 17220 E Unity   :      at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)

Does that mean I don’t have some PGP libraries installed from what…the SDK Manager?

All I can say is some part of the integration necessary did not take place. :slight_smile:

This could result from about ten billion different sources of error.

One approach is to restart the integration process from scratch, possibly on an empty project with the same bundle ID. This has the side benefit of confirming there are no conflicting issues with other build steps in your main project.

Another approach is to redo it on top of what you have right now to cross verify it.

It’s annoying, but there’s really not a lot of better ways to go about this stuff. :confused:

I agree, that’s my mindset right now. I like the idea of doing it in an empty project too. I think I’ll do that just to make sure I dot and cross every possible letter I come across. Thanks for the help.

1 Like

It kinda sucks but that is just the best way to go forward with these things, since even IF you do 100% of the steps correctly, other things (build steps, tool failures, etc.) can still fail these integrations out. The number of ways I have seen them fail (and for the most obtuse of reasons too) is almost legendary.

Good luck. Stay calm and rebuild the binary. :slight_smile:

Oh yeah, here’s an example of a “you can do everything right and it still won’t build” from 2 months ago:

Android build not building:

Recently (circa July 2022) there have been reports of Unity’s installer failing to install the Android Tools.

https://discussions.unity.com/t/887277

If it’s not that, then here’s how to troubleshoot:

First, make a blank project with a single blank scene and prove that it builds successfully.

If it does NOT build, then go fix your Unity installation, or your other tools, such as Android SDK, NDK, JDK, etc.

Until you can build a blank project to the target platform, don’t fiddle with anything else.

Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

Most often things that prevent building are third-party libraries such as Firebase.

Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

It may also be helpful to work through a tutorial or two for that subsystem.

Hah, I appreciate it, and that is all too real. The sheer number of layers in these systems can be overwhelming - a bug/error popping up feels like a kidney shot, lol.

1 Like

Luckily the complexity of the game is minimal, and besides PlayFab, I don’t use many other 3rd APIs and such, so hopefully building this out in a fresh project is just a seamless integration. I’ve already done it once a couple of years ago, so I mean…it has to work, lol…

Have you found a solution? I have a logcat running alongside a plugged in Android device, I got the same issue.

Having a few custom files for Gradle and one for Proguard, the latter already modified with this amount of text , has changed nothing. Force resolve didn’t change anything either.
The game uses a valid Unity project ID and is linked (otherwise using a debug key made it utterly impossible to run ‘Force Resolve’).

I haven’t had time to finish, but I was able to make it work in a new, empty project with the same bundle identifier. There must be some sort of conflict with the libraries or manifest. My next step will be to remove the FacebookSDK from my project and see if I can get it working.

Just for the sake of laughing, one of the Gradle errors I had was “solved” by allowing mimify (Proguard) for ‘Release’ (regardless of the IL2CPP mode used, like debug, release or master). I don’t like that because it makes no sense and it would be preferable if the building could proceed without ticking that option. The joke seems to be that the mimify:release purges some code somewhere that was creating a conflict. I found that lame solution from a stackoverflow thread from 2018 that mentioned something about Proguard that was vaguely related to the issue I was encountering.
Also, for those reading this, if your resolver fails, don’t use a debug key but use your custom key. For some obscure reason, this suddenly unlocks Unity’s Android Resolver’s ability to fetch the dependencies to update references and stuff.

1 Like