[Bug] DllNotFoundException: FirebaseCppApp-12_6_0 assembly:<unknown assembly> type:<unknown type> member:(null)
Description
I am getting the error in the title in my unity project.
This unity project pulls data from my firestore database on start. From March until maybe mid-May, everything has worked perfectly. Then suddenly, I was getting this error on my editor. This error does not come up on my colleague's machines who are working on the same repo/branch at times.
I have tried reinstalling Unity, deleting library folder and recompiling, deleting firebase modules and reimporting. Same error.
I can temporarily fix the issue by changing the settings on the dll file (FirebaseCppApp-12_6_0) in x86_64 folder. If I turn OFF 'Editor' on 'Include Platforms', somehow it starts working. This is temporary because if I close and open the project then this 'fix' does not continue working.
Colleagues on the exact same branch do not have the issue. I have not touched any firebase setting when it was originally imported. All I have done is write code to access the database and it has worked fine until now.
Reproducing the issue
May be difficult to reproduce since this has happened suddenly and not on my colleague's machines.
Try:
- Import SDK into new project on same editor (only using Firestore package)
- do:
void Start()
{
// Initialize Firestore
db = FirebaseFirestore.DefaultInstance;
}
- See if error occurs
Firebase Unity SDK Version
12.6.0
Unity editor version
6000.0.33f1
Installation Method
.unitypackage
Problematic Firebase Component(s)
Firestore
Other Firebase Component(s) in use
No response
Additional SDKs you are using
None.
Targeted Platform(s)
Android
Unity editor platform
Windows
Scripting Runtime
IL2CPP
Release Distribution Type
Pre-built SDK from https://firebase.google.com/download/unity
Relevant Log Output
DllNotFoundException: FirebaseCppApp-12_6_0 assembly:<unknown assembly> type:<unknown type> member:(null)
Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/linux_unity/app/swig/Firebase.App_fixed.cs:3958)
Rethrow as TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
Firebase.AppUtilPINVOKE..cctor () (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/linux_unity/app/swig/Firebase.App_fixed.cs:3978)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.AppUtilPINVOKE' threw an exception.
Firebase.AppUtil.SetLogFunction (Firebase.LogUtil+LogMessageDelegate arg0) (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/linux_unity/app/swig/Firebase.App_fixed.cs:4688)
Firebase.LogUtil..ctor () (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/app/src/LogUtil.cs:81)
Firebase.LogUtil..cctor () (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/app/src/LogUtil.cs:37)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.LogUtil' threw an exception.
Firebase.FirebaseApp..cctor () (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/linux_unity/app/swig/Firebase.App_fixed.cs:1924)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.FirebaseApp' threw an exception.
Firebase.Firestore.FirebaseFirestore.get_DefaultInstance () (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/firestore/src/FirebaseFirestore.cs:129)
FirebaseManager.Start () (at Assets/Scripts/UI+Menu+Settings/FirebaseManager.cs:27)
If using CocoaPods for Apple platforms, the project's Podfile.lock
Expand Podfile.lock snippet
👀 Replace this line with the contents of your Podfile.lock!
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hi @CQVEC , thank you for raising this issue. Could you please confirm there is no change has been made to the project setup, environment, or Unity/firebase versions before the error starts to show?
Could you please try test in a new, empty project (as you suggested). Create a brand new Unity project, import only the Firebase packages, add a minimal code(the one u suggested) and run. If the error doesn't occur here, it strongly suggests something specific to your existing project's setup or environments.
Hi @milaGGL I get the same error on a fresh project.
I have not touched at any point firebase settings, or attempted to upgrade the firebase version during development.
Any other unity environment options MAY have been changed but would be hard to pinpoint what exactly. Plus, I would expect these to carry over to my colleagues through version control.
update 1: after testing more with colleagues and trying to get the exact same project state through version control, they now also have the error
update 2: I have also tried upgrading to 12.9 SDK and same error
update 3: the x86_64 folder after importing the sdk is in Assets/Firebase/Plugins. If I move it to Assets/Plugins, it starts working. However if I then restart Unity it stops working, so if I move it back to its original location it starts working again. But only in the current session
update 1: after testing more with colleagues and trying to get the exact same project state through version control, they now also have the error
Can you list what changes have been done?
update 1: after testing more with colleagues and trying to get the exact same project state through version control, they now also have the error
Can you list what changes have been done?
there have been no changes made to firebase files. testing with colleagues was purely just merging our development branches together to ensure they had the same project state as me. I've checked history on firebase files and nothing has been touched
as I say when I moved the files around just to see if that made a difference, it did but didn't persist with a restart
Hi @CQVEC
Typically this error happens when Unity is failing to load the dll for a couple of different reasons. Based on the error you posted, I'm assuming this is in play mode in the editor? That DLL is a native library, so Unity also only loads it once and caches the result until you close and reopen the editor, so that might explain some of the odd behavior you are seeing.
The most common problem is a mismatch of versions, so make sure that all of your Firebase libraries are from the same version. They should be tagged with "Gvh_version-12.6.0" (or 12.9.0 if you updated).
One tip to uncover problems with it, if you look at it with the Inspector, there is a setting "Load on startup". That will force it to try to load immediately, and if there are any errors, it will log them in the console.
Hi @a-maurice
Yes it's through play mode in the editor I have this issue.
I looked at the libraries and it's all the same version (12.6). I did a fresh install of that version and also a fresh install of 12.9 to see if there was any difference. I removed the packages both manually and through the external dependency manager.
I've tried toggling on and the load on startup on the x86_64 dll file, I think it's a slightly different error log:
DllNotFoundException: FirebaseCppApp-12_6_0 assembly:<unknown assembly> type:<unknown type> member:(null) Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () (at <5b479f12ec104afb99c28526e5fe5bab>:0) Rethrow as TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. Firebase.AppUtilPINVOKE..cctor () (at <5b479f12ec104afb99c28526e5fe5bab>:0) Rethrow as TypeInitializationException: The type initializer for 'Firebase.AppUtilPINVOKE' threw an exception. Firebase.AppUtil.SetLogFunction (Firebase.LogUtil+LogMessageDelegate arg0) (at <5b479f12ec104afb99c28526e5fe5bab>:0) Firebase.LogUtil..ctor () (at <5b479f12ec104afb99c28526e5fe5bab>:0) Firebase.LogUtil..cctor () (at <5b479f12ec104afb99c28526e5fe5bab>:0) Rethrow as TypeInitializationException: The type initializer for 'Firebase.LogUtil' threw an exception. Firebase.FirebaseApp..cctor () (at <5b479f12ec104afb99c28526e5fe5bab>:0) Rethrow as TypeInitializationException: The type initializer for 'Firebase.FirebaseApp' threw an exception. Firebase.Firestore.FirebaseFirestore.get_DefaultInstance () (at <30677e59531a413fb93705421e936cbc>:0) FirebaseManager.Start () (at Assets/Scripts/UI+Menu+Settings/FirebaseManager.cs:27)
update: also Unity 6000.48, completely fresh project and still the same error.
Since this is now not just on my machine and is on a different version, it must be some form of global setting across Unity editors? I am really not sure what else to try now
@CQVEC So, when you toggle the load on startup, it should throw an error immediately without needed to actually start play mode, assuming there is a problem with the library itself. Also, since you are on Windows, make sure that you are editing the .dll file, and not the similarly named .bundle (for Mac) or .so (for Linux)
I'm not sure why it would be having problems with locating the dll file, especially if it is happening across multiple machines. Generally this type of problem shows up gives more info when turning on "Load on startup", or can just be fixed with resetting the Unity editor. Have you seen this with any of the other Firebase products, or just Firestore?
@a-maurice
so with the load on startup enabled on the dll, there is no error when I launch Unity. it's only when I press play through the editor. I'm not using any other Firebase products, all I have imported is Firestore.
update: it's now not happening anymore on a colleague's machine. they've not changed anything either, it's just started working for them again.
I feel like I have exhausted all possible options.
can anyone still assist with this?