Unity and Firebase Database 7.0.2 : Fallback handler could not load library

Viewed 1397

I've just integrated Firebase Auth within my project which works great. Database is created on the Firebase portal.

After integrating Firebase Database (which for some obscure reason doesnt show within the Unity Package Manager), when calling database = FirebaseDatabase.DefaultInstance; at start, the editor freezes.

I checked the Editor log which ends with what I've copy pasted below. I've seen some posts here about it being an issue with firebase 6.10 but I'm on 7.0.2 here. Wondering if you all had any ideas?

Editor log:

Fallback handler could not load library /Applications/Unity/Hub/Editor/2019.4.11f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Firebase/Plugins/x86_64/FirebaseCppApp-7_0_2.bundle Fallback handler could not load library /Applications/Unity/Hub/Editor/2019.4.11f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Firebase/Plugins/x86_64/FirebaseCppApp-7_0_2.bundle.dylib Fallback handler could not load library /Applications/Unity/Hub/Editor/2019.4.11f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Firebase/Plugins/x86_64/FirebaseCppApp-7_0_2.bundle.so Fallback handler could not load library /Applications/Unity/Hub/Editor/2019.4.11f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Firebase/Plugins/x86_64/FirebaseCppApp-7_0_2.bundle Loaded scene 'Temp/__Backupscenes/0.backup'

Edit#1: First of all thank you both for your lengthy answers. I will try to reimport the bundle files within the project and report back to you. I should note that the path that is listed in the editor log actually doesnt exist within my Unity.app package content. It finds Contents and Frameworks, but then Mono doesnt exist... After adding CakeCommander's registry to my Packages/Manifest.json I finally managed to have the Google LLC section of the package manager and re-import both Realtime Database and Auth from there, so that's good. I should note as well that now all of the SDK's folders exist in the Packages folder and nothing's in Assets anymore. I'm not using any version control for the time being.

Editor Log when it hangs forever

2 Answers

You might need to add The Google game package registry to your Packages/Manifest.json file your Unity Project.

This should look like:

{
  "scopedRegistries": [
    {
      "name": "Game Package Registry by Google",
      "url": "https://unityregistry-pa.googleapis.com",
      "scopes": [
        "com.google"
      ]
    }
  ],
  "dependencies": {
    ...
  }
}

You will need to restart Unity, for it to recognise this change.

I'd suggest reimporting via the package Manager in case of potential misconfiguration.

I'll start with that this looks like it's an Editor only issue as you've posted it (I wouldn't be surprised if it occurred on your device). To break down this specific log, the Firebase Unity SDK consists of three parts:

  1. a C# Unity library that you can use from typical Unity code
  2. a cross platform C++ layer for game developers
  3. a native iOS/Android layer to hook into each operating system -or- a C++ implementation of those native layers for Windows, Linux, and MacOS.

It looks like layer 3 is missing, at least on Desktop. The files that are missing are .bundle files which are basically shared libraries for macOS. So one of three things could be happening:

  1. MacOS Catalina (and newer) have really strict protections over what can and can't run. You may need to explicitly allow the .bundle files for MacOS for the Unity Editor to connect with the Firebase libraries. I've recorded a video about this, but the general gist is that you need to re-install the Firebase plugin, run Unity (you should get a security popup), dismiss the popup without deleting anything, then allowing Firebase in your computer's security settings.

  2. you've excluded the .bundle files from your project. Either when importing the SDK or when adding your project to source control (sometimes these are excluded as "build artifacts"). In order to test Firebase in editor on your mac, you will need to include this .bundle file. This might be as simple as re-importing the FirebaseDatabase.unitypackage and ensuring that FirebaseCppDatabase.bundle and related .bundle files are included:

Image with FirebaseCppDatabase.bundle highlighted in the "Import Unity Package" window

Note that if you did clone your project from source control, you will want to find your exclude rules and ensure that bundle files get committed.

  1. The related .bundle files might not be associated with the Editor build target. This usually occurs either when folks are tweaking the build system (ex: experimenting with .asmdef files) or are gun-shy about including .meta files in their commits. You'll want to make sure that the .bundle files are included in the "Editor" builds to run in Editor and "Standalone" if you ever want to spin off a macOS native build of your game with Unity:

Screenshot with FirebaseCppDatabase.bundle open in the Unity Inspector. Under "Select platforms for plugin", Editor and Standalone are checked

Note that @CakeCommander's suggestion may fix your issue as well. The PackageManager installs the Firebase SDK next to rather than inside your Assets/ directory, and Unity will know how to fetch this on each machine when needed. It's unlikely that any developers or version control software will be able to break the install. I will note that the External Dependency Manager for Unity used to automatically migrate packages to the package manager, but does not anymore - so I might wait for that feature to be reimplemented before messing with the package registry directly but it could also be your easiest path forward.

Related