firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
216 stars 35 forks source link

[Bug] DllNotFoundException: Unable to load DLL 'FirebaseCppApp-12_1_0' #1084

Open ClairePeta-36 opened 1 month ago

ClairePeta-36 commented 1 month ago

Description

Exception: System.TypeInitializationException: The type initializer for 'Firebase.FirebaseApp' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Firebase.LogUtil' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Firebase.AppUtilPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Firebase.AppUtilPINVOKE.SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'FirebaseCppApp-12_0_0'. Tried the load the following dynamic libraries: Unable to load dynamic library 'FirebaseCppApp-12_0_0' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "FirebaseCppApp-12_0_0" not found

DllNotFoundException: Unable to load DLL 'FirebaseCppApp-12_0_0'. Tried the load the following dynamic libraries: Unable to load dynamic library 'FirebaseCppApp-12_0_0' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "FirebaseCppApp-12_0_0" not found

Reproducing the issue

We are in the process of updating out app to unity 2022.3.35f1 We updated our firebase version from 9.1.0 to 12.1.0. while the build succeeds, on arriving to the home screen we get the above errors. We have done some research into others who have faced this problem however none of their fixes have worked for us

Attempted Resolutions:

Firebase Unity SDK Version

12.1.0

Unity editor version

2022.3.35f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

No response

Other Firebase Component(s) in use

Analytics, Crashlytics, In-App Messaging, Remote Config

Additional SDKs you are using

No response

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

No response

If using CocoaPods for Apple platforms, the project's Podfile.lock

Expand Podfile.lock snippet
```yml 👀 Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 1 month ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

argzdev commented 1 month ago

Thanks for reaching out, @ClairePeta-36. Firebase version 12.0.0+ requires a higher version of AGP and Gradle to work. I'm not sure if manually updating the Gradle is enough to fix the issue, since it also relies on the AGP version as well. In this case, could you try using version 2022.3.41f1 and see if it works? Thanks!

seanlcnr commented 1 month ago

@argzdev , I tried with 2022.3.41f1 but still same error. It doesn't happen when I install the built apk to an android device. However, in editor, in play mode it always shows up.

DllNotFoundException: FirebaseCppApp-12_0_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)

The project is at the latest unity supported gradle (com.android.tools.build:gradle:7.4.2).

This is really annoying. Google set a deadline to target API level 34. Firebase brings Android 14 support after 12.0.0. And we still dealing with dll errors.

argzdev commented 1 month ago

Could you answer a few questions below:

  1. Just as a sanity check, you mentioned that you're using the latest version of ED4MU. We recently fixed an issue with the unity-jar-resolver, and released it last week in version 1.2.182. Are you using this version? I noticed that our Packages download page is still linked to the old version 1.2.177 for latest versions of Firebase Unity SDKs 12.2.0. I think this might've cause the confusion.

  2. Also have you tried to use the Resolve or Force Resolve option:

    • Assets > External Dependency Manager > Android Resolver > Resolve
    • Assets > External Dependency Manager > Android Resolver > Force Resolve
  3. What Firebase products are you using? Do you have an MCVE for us to investigate this further?

This is really annoying. Google set a deadline to target API level 34. Firebase brings Android 14 support after 12.0.0. And we still dealing with dll errors.

Sorry you have to deal with this mess. Unfortunately, this is a mix of version incompatibility where AGP, Gradle, ED4MU, and Unity Editor needs to have the correct versions to work properly. But this has been resolved, and should work with the latest versions.

In any case, according to the Unity forums regarding API 34 issues, you may also request for an extension:

The deadline for targeting API 34 is August 31 - what if I don’t have enough time?

  • We have informed Google about the impact of this AGP issue to Unity Creators. You are allowed to request an extension until November using the usual Google Play Console / Policy pages 16. Usually this opens around the beginning of August. Please mention Unity 2021 and AGP/Legacy Library issues in your extension request.
seanlcnr commented 1 month ago

@argzdev , Thanks for your quick response. I use Android Resolver version 1.2.182. I tried Firebase 12.2.0 too with this resolver version, it still throws the same error. Please note that, I can build it and run it in a real Android device. There is no problem in an Android device (with Android 14). This only happens in Editor, in Play mode. I have many remote controls from Firebase RemoteConfig. So, the DLL error at the beginning, even for Editor's play mode, makes my development very difficult. It completely disables remote config activities.

2- I tried both of them, there is still error :( 3- FirebaseAnalytics, FirebaseMessaging, FirebaseRemoteConfig.

The error starts when it calls RemoteConfig methods as the following:

DllNotFoundException: FirebaseCppApp-12_2_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. Rethrow as TypeInitializationException: The type initializer for 'Firebase.FirebaseApp' threw an exception. Firebase.RemoteConfig.FirebaseRemoteConfig.get_DefaultInstance () (at /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/remote_config/src/FirebaseRemoteConfig.cs:164)

image

image

argzdev commented 1 month ago

Thanks for the extra details, @seanlcnr. Hmm, that's interesting. I tried testing with our Firebase Unity Quickstart adding Firebase SDK v12.2.0 via Import Asset or Package Manager. Both methods seems to run correctly in the Unity Editor 2022.3.40f1 or with the built Android app.

I'm wondering, if it works on building an Android app, could it be a permission error? Can you check this Stack Overflow thread:

  • Remove Firebase and external library folder from Assets.
  • Import again.
  • Run Unity, you will get popup of unidentified developer. And you have only two options in popup so you can select to move to bin.
  • Then in system preferences -> Allow bundle.
  • Open Bin and drag and drop deleted bundle which is "FirebaseCppApp-11_6_0.bundle" to Assets in Unity.
  • Make sure settings allow that bundle.
  • Run Unity and it will run project successfully!

Either that, or the Firebase packages were not imported properly. You might have to try re-importing all Firebase packages including the ED4MU and then do a clean build. In case you've used Assets > Import Package > Custom Package, you can use Assets > External Dependency Manager > Version Handler > Uninstall Managed Packages to properly remove all added Firebase assets to make sure no random files are left before adding via Package Manager.

Let me know if these help!

seanlcnr commented 1 month ago

@argzdev thanks for your detailed guide.

I did apply everything you said, but it still throws the same error. I also tried opening Unity as administrator mode.

FirebaseCppApp-12_2_0.dll
FirebaseCppApp-12_2_0.so
FirebaseCppApp-12_2_0.bundle

These files are under Assets/Firebase/Plugins/x86_64 folder. My OS is Windows 10 Enterprise LTSC - 64-bit. Does it really check exaclty this folder? Should I move these files to another folder? I think this is only a "read" operation. It doesn't try to write/change these files, it only reads, but cannot find the file some how. Does it still need an additional permission at the OS level?

By the way, Firebase version 11_1_0 works fine on the same OS, same Unity version, same project. However, it doesn't support Android 14 I guess. So I have to stay at 12_0_0+

Seanm07 commented 3 weeks ago

I'm finding that recently the latest Firebase and ED4MU DLLs keep changing their platform settings either unmarking the current platform or unmarking all platforms which causes DLL not found errors like the one you've encountered.

I'm not sure what causes these platform settings to change but I've ran into this issue multiple times with different projects since updating to Firebase 12.2.0

seanlcnr commented 3 weeks ago

Hi @Seanm07 , thanks for your answer. They are all Editor ticked. The error still remains.

Did you solve this in your case?

Years ago, I was in trouble with another Firebase error and it was solved in almost 3 years with a new Firebase release:) Hope this one will be solved earlier.

argzdev commented 3 weeks ago

Thanks for the extra details, @seanlcnr. So far, I'm unable to reproduce the same behavior. I'm wondering if the issue is due to the different OS being used. Currently, I'm testing with a macOS Sonoma 14.6.1 , we don't have a Windows device ready for testing, so we'll try and figure something out. By the way, is there any difference in behavior if you import the Firebase SDK using the Assets > Import Package > Custom Package?

ClairePeta-36 commented 3 weeks ago

We are still experiencing this issue on all android builds, our IOS and windows builds are running as expected; we have noticed that when we open the apk in Android studio the file can be seen in the lib folder as shown below image We have tried updating to the latest unity version; 2022.3.43f1 with no difference, we have currently downgraded to the 11.9.0 firebase and targeting API 33 to see if that resolves the issue but so far no difference. We have tried all the version of EDM ranging from the one installed with the 11.9.0 firebase packages up to the latest release. Also tried on numerous computer with fresh installs of unity just incase it was something local

argzdev commented 3 weeks ago

Sorry, we're still unable to reproduce the same behavior. Are you able to reproduce this behavior on a fresh project? If so, could you share with us an MCVE, so we can investigate further?

ClairePeta-36 commented 2 weeks ago

This morning i have tested a brand new project in 2022.3.35f1. Installed the gpgs-0.11.0 unity package, FirebaseCrashlytics_11.9.0 package, and the FirebaseAnalytics_11.9.0 package. I added a script to init firebase (FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread()) on start. and on an android build i am still receiving the following error image

argzdev commented 2 weeks ago

It could be a configuration issue, but again, without a proper MCVE, it'll be difficult for us to investigate this further especially since we aren't encountering this behavior on our side. You may also try using our Firebase Quickstart for references. Thanks

Ls9257 commented 1 week ago

谢谢你提供更多详细信息,@seanlcnr。嗯,这很有趣。我尝试使用我们的Firebase Unity Quickstartv12.2.0通过Import Asset或添加 Firebase SDK进行测试Package Manager。这两种方法似乎都可以在 Unity 编辑器2022.3.40f1或内置的 Android 应用中正确运行。

我想知道,如果它可以构建 Android 应用,那么这可能是权限错误吗?您可以查看这个Stack Overflow 线程吗:

  • 从 Assets 中删除 Firebase 和外部库文件夹。
  • 再次导入。
  • 运行 Unity,您将看到未识别开发人员的弹出窗口。弹出窗口中只有两个选项,您可以选择将其移至 bin。
  • 然后在系统偏好设置->允许捆绑。
  • 打开 Bin,将已删除的 bundle “FirebaseCppApp-11_6_0.bundle” 拖放到 Unity 中的 Assets 中。
  • 确保设置允许该捆绑。
  • 运行Unity,项目将成功运行!

要么是 Firebase 包没有正确导入。您可能必须尝试重新导入所有 Firebase 包(包括 ED4MU),然后进行全新构建。如果您使用了Assets > Import Package > Custom Package,则可以使用Assets > External Dependency Manager > Version Handler > Uninstall Managed Packages正确删除所有添加的 Firebase 资产,以确保在通过 添加 之前没有遗留任何随机文件Package Manager

如果这些有帮助的话请告诉我! This worked for me, I also had the same error, I tried to delete all firebase packages and import the latest Firebase version 12.2.0 successfully resolved this error

seanlcnr commented 4 days ago

Hi @Ls9257 . Thanks for your suggestion. Unfortunately, my condition still remains.

Btw, I just upgraded Firebase to 12.2.1. Nothing changed, there is still the same error.

grantwwoodford commented 2 days ago

I am experiencing the exact same issue. The error only occurred when I upgraded my project to use the latest Firebase SDK in order to support the new Target API Level.

Firebase Unity SDK Version 12.2.1

Unity editor version 2022.3.45f1

Installation Method .unitypackage

Problematic Firebase Component(s) Auth

Targeted Platform(s) Editor

Unity editor platform Ubuntu 20.04

Scripting Runtime IL2CPP

Could the problem be a dependency issue. What is the required GLIBC version?

I ran a dependency check and got this:

~/git/FirebaseSample/Assets/Firebase/Plugins/x86_64$ ldd FirebaseCppApp-12_2_1.so
./FirebaseCppApp-12_2_1.so: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./FirebaseCppApp-12_2_1.so)
./FirebaseCppApp-12_2_1.so: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./FirebaseCppApp-12_2_1.so)
./FirebaseCppApp-12_2_1.so: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./FirebaseCppApp-12_2_1.so)
    linux-vdso.so.1 (0x00007ffff5377000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fc7c0bd9000)
    libsecret-1.so.0 => /usr/lib/x86_64-linux-gnu/libsecret-1.so.0 (0x00007fc7c0b78000)
    libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fc7c0a4e000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc7c07e0000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc7c0691000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc7c066a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc7c0478000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fc7c4f57000)
    libgcrypt.so.20 => /usr/lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fc7c035a000)
    libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007fc7c0178000)
    libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fc7c0118000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc7c00f5000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fc7c0080000)
    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fc7c005d000)
    libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fc7c0057000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc7c0051000)
    libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007fc7bfff1000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fc7bffc6000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fc7bffa8000)
    libffi.so.7 => /usr/lib/x86_64-linux-gnu/libffi.so.7 (0x00007fc7bff9c000)
    libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007fc7bff45000)
    libpcre2-8.so.0 => /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007fc7bfeb4000)

Created a minimal test project: https://github.com/grantwwoodford/FirebaseSample

Perhaps you can reproduce on Ubuntu 20.04 if it is related to some OS library?

Update

The issue went away when I upgraded to Ubuntu 22.04.