Thaina / google-signin-unity

Google Sign-In API plugin for Unity game engine. Works with Android and iOS.
Other
29 stars 9 forks source link

NullReferenceException on silentSignIn #2

Closed Deathwing closed 8 months ago

Deathwing commented 9 months ago

When doing a silentSignIn on Android, which definetly should fail (as I am not logged in), which it also does with the following error: SignInFragment Error with silentSignIn: Status{statusCode=4: , resolution=null}

I afterwards get an unhandled NullReferenceException within the GoogleSignInImpl:

Unity NullReferenceException: Object reference not set to an instance of an object.
at Google.Impl.GoogleSignInImpl+SignInListener.OnResult (System.Int32 result, UnityEngine.AndroidJavaObject acct) [0x00011] in ./Library/PackageCache/com.google.signin@62ac175412/GoogleSignIn/Impl/GoogleSignInImpl.cs:139 
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0 
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x001a5] in /home/bokken/build/output/unity/unity/Modules/AndroidJNI/AndroidJava.cs:174 
at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, UnityEngine.AndroidJavaObject[] javaArgs) [0x00055] in /home/bokken/

So changing:

      public void OnResult(int result, AndroidJavaObject acct)
      {
        Debug.Log("googlesignin.IListener : " + acct.Call<string>("toString"));
        Debug.Log("ID : " + acct.Call<string>("getId"));
      }

To:

      public void OnResult(int result, AndroidJavaObject acct)
      {
        Debug.Log("googlesignin.IListener : " + acct?.Call<string>("toString"));
        Debug.Log("ID : " + acct?.Call<string>("getId"));
      }

Would already resolve the issue :)

Also for testing the plugin on MacOS Editor, its hard to test it, as the port is always changing, while the Google OAuth2 client requires an exact redirect URL :)

Thaina commented 9 months ago

Thanks for your report. But I think if we use localhost:**** url as prefix and redirect. We can then specified any redirect port though?

image

Deathwing commented 9 months ago

Yeah, you are right regarding the authorised uri, I was just dumb :D