- Home /
Firebase initialization halts Start () and Update () functions
The initialization suggested on the Firebase for Unity page includes a certain CheckAndFixDependenciesAsync() function which causes Start () and Update () to stop functioning on android build (anything that needs these methods doesn't work, buttons work as normal). The game is totally fine in the editor and the firebase check returns positive. I call the following script from the Awake() method of my gamecontrol script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class FirebaseAnalyticsInitialize {
public static bool firebaseReady;
public static void CheckIfReady () {
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
Firebase.DependencyStatus dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available) {
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
firebaseReady = true;
Debug.Log ("Firebase is ready for use.");
// Create and hold a reference to your FirebaseApp, i.e.
// app = Firebase.FirebaseApp.DefaultInstance;
// where app is a Firebase.FirebaseApp property of your application class.
// Set a flag here indicating that Firebase is ready to use by your
// application.
} else {
firebaseReady = false;
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
}
}
Answer by Tuonela · Nov 28, 2018 at 02:20 PM
Calling the function from Start() instead of Awake() solved the problem. Don't know what was causing the issue though, as the firebase guide simply says run this check at the start of your application which doesn't sound like it should be specifically the start () function.
Answer by SanderGoal043 · Nov 04, 2019 at 02:39 PM
Hi
I had a similar problem and stumbled upon this page.
CheckAndFixDependenciesAsync() would stop in the middle of the function without any errors.
In my case it stopped when i invoked an event.
Based on some quick google this has to do with the async nature of CheckAndFixDependenciesAsync.
this runs on a different thread, so you cant call the unity api. the function throws an error, but because its on a different thread, unity doesn't seem to catch it
unity's debug endpoint does work on a different thread,
using a try catch u can force the errors back in to unity