Quickstart-unity: Don't call Firebase functions before CheckDependencies has finished

Created on 7 Sep 2018  路  6Comments  路  Source: firebase/quickstart-unity

09-07 10:59:28.508 12117-12176/? E/Unity: InvalidOperationException: Don't call Firebase functions before CheckDependencies has finished
at Firebase.FirebaseApp.ThrowIfCheckDependenciesRunning () [0x00000] in :0
at Firebase.FirebaseApp.GetInstance (System.String name) [0x00000] in :0
at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in :0
at Firebase.Auth.FirebaseAuth.get_DefaultInstance () [0x00000] in :0
at Manager.FirebaseManager.FirebaseAuthPlayGames () [0x00000] in :0
at Manager.FirebaseManager.m__1 (Boolean success) [0x00000] in :0
at GooglePlayGames.PlayGamesPlatform+c__AnonStorey1.<>m__0 (Boolean success, System.String msg) [0x00000] in :0
at GooglePlayGames.Native.NativeClient+c__AnonStorey1`2[System.Boolean,System.String].<>m__0 () [0x00000] in :0
at GooglePlayGames.OurUtils.PlayGamesHelperObject.Update () [0x

question

Most helpful comment

I have the same problem today and fixed with the next steps, my app uses Firebase Analitycs and Firebase Auth, from the quick start guide on each example the devs call this method

Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {})

ok.. this is correct if you have only one part of Firebase running in you project, but in my case, im using two parts, so from Auth, i delete the duplicated call to Firebase.FirebaseApp.CheckAndFixDependenciesAsync() and just calling it in the Analitycs script.

Then when firebase ends it's configuration on the Analitycs script, i call my Auth script but just the function InitializeFirebaseAuth.

And that fix it for me, maybe it will help you.

All 6 comments

Can you show the code that's causing this? Are you calling into Firebase functions before CheckDependencies has finished?

I have the same problem today and fixed with the next steps, my app uses Firebase Analitycs and Firebase Auth, from the quick start guide on each example the devs call this method

Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {})

ok.. this is correct if you have only one part of Firebase running in you project, but in my case, im using two parts, so from Auth, i delete the duplicated call to Firebase.FirebaseApp.CheckAndFixDependenciesAsync() and just calling it in the Analitycs script.

Then when firebase ends it's configuration on the Analitycs script, i call my Auth script but just the function InitializeFirebaseAuth.

And that fix it for me, maybe it will help you.

thanks @kaozgaia! also solved my case :)

Sounds like folks on this thread can now use System.Threading.Tasks.Task :) .

Can we re-open this issue? We're facing the same crash, but with a small number of users only.
Firebase is used only in one place:

void Start() {
      Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
        var dependencyStatus = task.Result;
        if (dependencyStatus == Firebase.DependencyStatus.Available) {
          InitFCM();
        } else {
          Debug.LogError(System.String.Format("Could not resolve all Firebase dependencies: {0}", dependencyStatus));
          // Firebase Unity SDK is not safe to use here.
        }
      });

    }

    public void InitFCM() {
      Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
      Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
      // On Notification Click
#if UNITY_ANDROID
      // On click notification listener
      UTNotifications.Manager.Instance.OnNotificationClicked += (NotificationClicked) => {
        if (NotificationClicked.userData != null) {
          string notificationURL = NotificationClicked.userData["url"];
          // If the URL in the notification is not null
          if (notificationURL != null) {
            DeepLinking.GoTo(notificationURL); // GO FOR IT
          }
        }
      };
#endif
    }

Hi @Sh3rawi

If you are experiencing this issue, can you create a new issue, and fill out all the info in the fields. It'll help us track down the problem you might be seeing.

Was this page helpful?
0 / 5 - 0 ratings