Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Google Play Games plugin doesn't initialize

Discussion in 'Editor & General Support' started by MAWMatt, Oct 4, 2022.

  1. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    58
    Hey folks,

    I've been going through the process of integrating Google Sign-In into my game. I'm using the https://github.com/playgameservices/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:
    Code (CSharp):
    1. PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().AddOauthScope( "profile" ).RequestIdToken().RequestServerAuthCode( false ).Build();
    2.         PlayGamesPlatform.InitializeInstance( config );
    3.         PlayGamesPlatform.Activate();
    Now, however, the initialization is different and apparently not working for me.
    Code (CSharp):
    1. PlayGamesPlatform.Instance.Authenticate( ( status ) =>
    2. {
    3.     // this callback is never hit
    4. } );
    Does anyone know why this wouldn't even return with a failure but instead just hang?

    Thanks!
    -Matt
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,391
    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.
     
  3. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    58
    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?!)
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,391
    Bust out your
    adb logcat
    and see if there's any actionable noise in the log output.
     
  5. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    58
    Thanks for the suggestion, it appears the following error pops up trying to initialize the plugin:

    Code (CSharp):
    1. AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
    2. 10-05 15:43:40.111 17091 17220 E Unity   : java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
    3. 10-05 15:43:40.111 17091 17220 E Unity   :      at java.lang.Class.classForName(Native Method)
    4. 10-05 15:43:40.111 17091 17220 E Unity   :      at java.lang.Class.forName(Class.java:454)
    5. 10-05 15:43:40.111 17091 17220 E Unity   :      at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    6. 10-05 15:43:40.111 17091 17220 E Unity   :      at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
    7. 10-05 15:43:40.111 17091 17220 E Unity   :      at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
    8. 10-05 15:43:40.111 17091 17220 E Unity   :      at android.os.Handler.dispatchMessage(Handler.java:102)
    9. 10-05 15:43:40.111 17091 17220 E Unity   :      at android.os.Looper.loopOnce(Looper.java:226)
    10. 10-05 15:43:40.111 17091 17220 E Unity   :      at android.os.Looper.loop(Looper.java:313)
    11. 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?
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,391
    All I can say is some part of the integration necessary did not take place. :)

    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. :/
     
  7. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    58
    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.
     
    Kurt-Dekker likes this.
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,391
    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. :)

    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://forum.unity.com/threads/cant-build-for-android.1306098/

    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.
     
  9. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    58
    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.
     
    Kurt-Dekker likes this.
  10. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    58
    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...
     
  11. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    389
    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').
     
  12. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    58
    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.
     
  13. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    389
    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.
     
    ilmario likes this.