Build works in 2022.3.19, but crashes in 2022.3.25.

I’m running into a build inconsistency between unity versions 2022.3.19f1 and 2022.3.25f1. To preface, 2022.3.19 had a bug with the TMP input field where, on Android, the touchscreen keyboard wouldn’t always appear correctly. I was told it was fixed in 2022.3.25. After confirming it, I updated the project to that version.

However, when I build on the new version, I would get an null exception that I don’t get on the older version, or in both version of the editor. This only happens when I build it on Android, afaict. The app works perfectly fine in both versions of the editor, and works fine when built from the older version. The Null exception is caused by the Sign in functions for Firebase.Auth (SignInAnonymouslyAsync() and SignInWithEmailAndPasswordAsync()) inside a script called FirestoreAuthenticator.

The Bug I get on Android:

AndroidPlayer "Samsung_SM G973U@ADB:RF8MB27GHGA:0" NullReferenceException: Object reference not set to an instance of an object.
at FirebaseAuthenicator.SignInAnon () [0x0003d] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\FirebaseAuthenicator.cs:33
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at FirebaseAuthenicator.SignInAnon () [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckSignIn () [0x0002d] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\ConnectivityCheck.cs:46
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckSignIn () [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckConnectivity () [0x00065] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\ConnectivityCheck.cs:29
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckConnectivity () [0x00000] in <00000000000000000000000000000000>:0
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x00047] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\AppStartUp.cs:27
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x0001b] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:516
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.AppStartUp () [0x0000f] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:259
at UnityEngine.Events.InvokableCall.Invoke () [0x00016] in \home\bokken\build\output\unity\unity\Runtime\Export\UnityEvent\UnityEvent.cs:178
at UnityEngine.Events.UnityEvent.Invoke () [0x00023] in \home\bokken\build\output\unity\unity\artifacts\generated\UnityEvent\UnityEvent_0.cs:57
at UnityEngine.UI.Button.Press () [0x0002d] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:70
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00011] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:114
at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00008] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:57
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00073] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:272
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerButton (UnityEngine.InputSystem.UI.PointerModel+ButtonState& button, UnityEngine.EventSystems.PointerEventData eventData) [0x0023c] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:542
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointer (UnityEngine.InputSystem.UI.PointerModel& state) [0x001c3] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:344
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () [0x0008f] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:2169
at UnityEngine.EventSystems.EventSystem.Update () [0x000fc] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\EventSystem.cs:530
--- End of stack trace from previous location where exception was thrown ---
at ConnectivityCheck.CheckSignIn () [0x00086] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\ConnectivityCheck.cs:46
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckSignIn () [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckConnectivity () [0x00065] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\ConnectivityCheck.cs:29
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckConnectivity () [0x00000] in <00000000000000000000000000000000>:0
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x00047] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\AppStartUp.cs:27
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x0001b] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:516
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.AppStartUp () [0x0000f] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:259
at UnityEngine.Events.InvokableCall.Invoke () [0x00016] in \home\bokken\build\output\unity\unity\Runtime\Export\UnityEvent\UnityEvent.cs:178
at UnityEngine.Events.UnityEvent.Invoke () [0x00023] in \home\bokken\build\output\unity\unity\artifacts\generated\UnityEvent\UnityEvent_0.cs:57
at UnityEngine.UI.Button.Press () [0x0002d] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:70
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00011] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:114
at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00008] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:57
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00073] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:272
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerButton (UnityEngine.InputSystem.UI.PointerModel+ButtonState& button, UnityEngine.EventSystems.PointerEventData eventData) [0x0023c] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:542
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointer (UnityEngine.InputSystem.UI.PointerModel& state) [0x001c3] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:344
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () [0x0008f] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:2169
at UnityEngine.EventSystems.EventSystem.Update () [0x000fc] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\EventSystem.cs:530
--- End of stack trace from previous location where exception was thrown ---
at ConnectivityCheck.CheckConnectivity () [0x000c2] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\ConnectivityCheck.cs:29
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at ConnectivityCheck.CheckConnectivity () [0x00000] in <00000000000000000000000000000000>:0
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x00047] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\AppStartUp.cs:27
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x0001b] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:516
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.AppStartUp () [0x0000f] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:259
at UnityEngine.Events.InvokableCall.Invoke () [0x00016] in \home\bokken\build\output\unity\unity\Runtime\Export\UnityEvent\UnityEvent.cs:178
at UnityEngine.Events.UnityEvent.Invoke () [0x00023] in \home\bokken\build\output\unity\unity\artifacts\generated\UnityEvent\UnityEvent_0.cs:57
at UnityEngine.UI.Button.Press () [0x0002d] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:70
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00011] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:114
at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00008] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:57
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00073] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:272
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerButton (UnityEngine.InputSystem.UI.PointerModel+ButtonState& button, UnityEngine.EventSystems.PointerEventData eventData) [0x0023c] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:542
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointer (UnityEngine.InputSystem.UI.PointerModel& state) [0x001c3] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:344
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () [0x0008f] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:2169
at UnityEngine.EventSystems.EventSystem.Update () [0x000fc] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\EventSystem.cs:530
--- End of stack trace from previous location where exception was thrown ---
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x000a0] in C:\Work\Unity\Medical Cart\Assets\Scripts\Core Scripts\AppStartUp.cs:27
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at AppStartUp.StartUp (System.Boolean _skipCheckConnect) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x0001b] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:516
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.AppStartUp () [0x0000f] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:259
at UnityEngine.Events.InvokableCall.Invoke () [0x00016] in \home\bokken\build\output\unity\unity\Runtime\Export\UnityEvent\UnityEvent.cs:178
at UnityEngine.Events.UnityEvent.Invoke () [0x00023] in \home\bokken\build\output\unity\unity\artifacts\generated\UnityEvent\UnityEvent_0.cs:57
at UnityEngine.UI.Button.Press () [0x0002d] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:70
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00011] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:114
at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00008] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:57
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00073] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:272
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerButton (UnityEngine.InputSystem.UI.PointerModel+ButtonState& button, UnityEngine.EventSystems.PointerEventData eventData) [0x0023c] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:542
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointer (UnityEngine.InputSystem.UI.PointerModel& state) [0x001c3] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:344
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () [0x0008f] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:2169
at UnityEngine.EventSystems.EventSystem.Update () [0x000fc] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\EventSystem.cs:530
--- End of stack trace from previous location where exception was thrown ---
at PanelManager.Continue () [0x00071] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:516
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.Continue () [0x00000] in <00000000000000000000000000000000>:0
at PanelManager.AppStartUp () [0x0000f] in C:\Work\Unity\Medical Cart\Assets\Scripts\MainSceneScripts\PanelManager.cs:259
at UnityEngine.Events.InvokableCall.Invoke () [0x00016] in \home\bokken\build\output\unity\unity\Runtime\Export\UnityEvent\UnityEvent.cs:178
at UnityEngine.Events.UnityEvent.Invoke () [0x00023] in \home\bokken\build\output\unity\unity\artifacts\generated\UnityEvent\UnityEvent_0.cs:57
at UnityEngine.UI.Button.Press () [0x0002d] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:70
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00011] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Button.cs:114
at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00008] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:57
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00073] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\ExecuteEvents.cs:272
at UnityEngine.InputSystem.UI.Inpu<message truncated>

The scripts involved is as follows:

using Firebase.Firestore;
using Firebase.Storage;
using UnityEngine;

public class FirestoreController : MonoBehaviour
{
    public static FirebaseFirestore firestoreInstance;
    public static FirebaseStorage firebaseStorage;
    public static Firebase.Auth.FirebaseAuth firebaseAuth;
    public static StorageReference storageRef;

    private void Awake() //sets up necessary firebase instances for the scene that has this attached.
    {
        firestoreInstance = FirebaseFirestore.DefaultInstance;
        firebaseStorage = FirebaseStorage.DefaultInstance;
        firebaseAuth = Firebase.Auth.FirebaseAuth.DefaultInstance;
        storageRef = firebaseStorage.GetReferenceFromUrl("address");
    }
}
using System.Collections;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;

public static class ConnectivityCheck
{
    private static FirebaseAuthenicator auth;

    public static FirebaseAuthenicator Authenticator
    {
        set { auth = value; }
    }

    public static async Task CheckConnectivity() //checks for connectivity. If there is, signs the user in anonymously. If not, returns a false bool.
    {
        if (Application.internetReachability == NetworkReachability.NotReachable) //checks for internet connection before proceeding.
        {
            ARTestModeStatics.WarningMessage("No network connection!");
            GameManager.noConnectivity = true;
        }
        else if (Application.internetReachability != NetworkReachability.NotReachable)
        {
            ARTestModeStatics.DebugMessage("Network Connection found.", 1);

            if (!GameManager.offlineMode)
            {
                GameManager.noConnectivity = false;
                await CheckSignIn();
            }
            else
                GameManager.noConnectivity = true;
        }
        else if (GameManager.offlineMode)
        {
            ARTestModeStatics.DebugMessage("Offline Mode Is ON.", 3);
            GameManager.noConnectivity = true;
        }
    }

    public static async Task CheckSignIn()
    {
        if (GameManager.signedInUser == null)
        {
            ARTestModeStatics.DebugMessage("User not signed in. Signing in Anonumously.", 1);
            await auth.SignInAnon();
        }
        else if (GameManager.signedInUser != null)
            ARTestModeStatics.DebugMessage("User already signed in as: " + GameManager.signedInUser.UserId, 2);
    }
}
using System.Threading.Tasks;
using UnityEngine;

public class FirebaseAuthenicator : MonoBehaviour
{
    [SerializeField]
    private string email, password;

    public string Email
    {
        set { email = value; }
    }

    public string Password
    {
        set { password = value; }
    }

    private void Awake()
    {
        ConnectivityCheck.Authenticator = this;
    }

    public async Task SignInAnon()
    {
        ARTestModeStatics.DebugMessage("Signing-In anonymously.", 1);

        if (GameManager.noConnectivity)
        {
            ARTestModeStatics.ErrorMessage("ERROR: Sign-In Anon aborted due to lack of connectivity.");
            return;
        }

        await FirestoreController.firebaseAuth.SignInAnonymouslyAsync().ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                return;
            }

            GameManager.signedInUser = task.Result;
            ARTestModeStatics.DebugMessage("User Signed-In as: " + GameManager.signedInUser.UserId, 2);
        });   
    }

    public async Task SignInAdmin()
    {
        ARTestModeStatics.DebugMessage("Signing-In as Administrator.");

        if (GameManager.noConnectivity)
        {
            ARTestModeStatics.ErrorMessage("ERROR: Sign-In aborted due to lack of connectivity.");
            return;
        }

        if (email == "" || password == "")
        {
            ARTestModeStatics.ErrorMessage("ERROR: Missing email or password. Sign-In aborted.");       
            return;
        }

        await FirestoreController.firebaseAuth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                return;
            }

            GameManager.signedInUser = task.Result;
            ARTestModeStatics.DebugMessage("User Signed-In as: " + GameManager.signedInUser.UserId, 2);
        });
    }

    public async Task CreateAccount()
    {
        if (GameManager.noConnectivity)
        {
            ARTestModeStatics.ErrorMessage("ERROR: Sign-In aborted due to lack of connectivity.");
            return;
        }

        await FirestoreController.firebaseAuth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                return;
            }

            GameManager.signedInUser = task.Result;
            ARTestModeStatics.DebugMessage("User Signed-In as: " + GameManager.signedInUser.UserId, 2);
        });
    }

    public void SignOut() //signs user out.
    {
        if (GameManager.signedInUser == null)
        {
            ARTestModeStatics.ErrorMessage("ERROR: User not signed in. Sign out skipped.");
            return;
        }

        FirestoreController.firebaseAuth.SignOut();
        ARTestModeStatics.DebugMessage("User Signed-Out", 1);
    }

    private void OnApplicationQuit()
    {
        SignOut();
    }
}

Both FirestoreController and FirestoreAuthenticator are placed on the same game object that is always enabled.

ConnectivityCheck is a static script shared between multiple scenes.

The way that the script works is that one Awake(), FirestoreController initiates Firebase references. FirebaseAuthenticator that sets itself as the static reference for “auth” within ConnectivityCheck. FInally Connectivity Checks checks if there is a internet connection before signing in with the appropriate sign-in method. In app, it’s always SignInAnon(), called by CheckSignIn().

The Null exception is in the SignIAnonymousAsync() (I tested it with SignInWithEmailAndPasswordAsync() as well, same bug).

I thought maybe the new version didn’t like the static ConnectivityCheck script, so I made a version that was non-static and placed it onto the same game object, where the references were serialized and assigned in the inspector - same bug.

From what I can tell, 2022.3.25f1 doesn’t seem to like how my Firebase is Initialized. Is there changes in the new version I need to be aware of? Is the version of Firebase not supported?

To summarize, the app works perfectly fine in BOTH version of the editor and when built on the 2022.3.19f1. No code was changed between the two build versions initially. And none of the code changes I made in an attempt to fix the issue fixes the bug. It’s the excact bug:

I’d check order of operations. Make sure everything is getting setup as you expect in the correct order.
For example, if two scripts both implement Awake, there is no guarantee the order those Awakes get called in. And even if they get called in the correct order in editor, they may get swapped in a build.

Next thing is calls to ContinueWith I find sometimes create issues and I think aren’t suggested for Unity as it doesn’t always return to the main thread correctly. Look into ContinueWithOnMainThread instead.
https://firebase.google.com/docs/reference/unity/class/firebase/extensions/task-extension

2 Likes

Thanks! I’ll give your suggestions a try with the ContinueWithOnMainThread.

I did use the Script Execution order thing in Preferences to set the script I want to have its Awake execute first moved to the very top, just below all the other Unity scripts. That didn’t solve the issue, though. I even assigned the references manually in the inspector, instead of using awake() and it still causes the same issue.

Is there a reason why it works in the older version, and in both version of the editor, but just not the new one? Does a projects settings not carry over when I move up a version or something?

You were correct regarding the ContinueWith(). That was the issue. Problem Fixed. Thanks for the help! :smile:

I’ve updated the project to Firebase SDK 12.0, because the 10.7 wasn’t building on iOS (but works perfectly fine on Android). The project now builds on iOS, but I’m now running into a similar problem with the null-exception that the previous mentioned fix no longer resolves. This is the code that is bugging out:

public async Task SignInAnon()
    {
        ARTestModeStatics.DebugMessage("Signing-In anonymously.", 1);

        if (GameManager.noConnectivity)
        {
            ARTestModeStatics.ErrorMessage("ERROR: Sign-In Anon aborted due to lack of connectivity.");
            return;
        }

        await FirestoreController.firebaseAuth.SignInAnonymouslyAsync().ContinueWithOnMainThread(task =>
        {
            if (task.IsCanceled)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                ARTestModeStatics.ErrorMessage("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                return;
            }

            GameManager.signedInUser = task.Result.User;
            ARTestModeStatics.DebugMessage("User Signed-In as: " + GameManager.signedInUser.UserId, 2);
        });
    }

This line causes the issue: await FirestoreController.firebaseAuth.SignInAnonymouslyAsync().ContinueWithOnMainThread

In Firebase SDK 12, I had to change task.Result to task.result.User to fix a compilation error. But now I get the same Null exception as I did before even with ContinueWithOnMainThread.

As before the app works fine in the Editor. I tried reverting back to ContinueWith, but that doesn’t work either. Not sure if its a Firebase SDK bug or a bug on my end.

Any ideas on a fix? I’ve attached a full error from Unity using the Dev Build script debugging.

PS: I also had to update the Android API to 34. Not sure if that has to do with anything, but the 33 I was using wasn’t building with the new Firebase SDK.


9858237–1419906–AndroidErrorFirebase12.txt (16 KB)

Update: the problem seems to be only on Android. The Newest build with Firebase SDK v12 builds and works fine on iOS.

Android SDK bug, maybe?

Problem fixed.

1 Like