我正在尝试在我的 Android 应用程序中使用 firebase unity sdk。具体来说是 FirebaseFirestore.unitypackage。我可以通过统一直接运行我的应用程序,让一切正常运行。但是当我进行 Android 构建并部署到我的实际设备或模拟器时,我收到此错误。
java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/my.package.name/cache/firestore_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
然后在日志中显示类似的内容...
E/firebase: Java class com/google/firebase/firestore/internal/cpp/QueryEventListener not found. Please verify the AAR which contains the com/google/firebase/firestore/internal/cpp/QueryEventListener class is included in your app
我尝试直接从 Unity 中“构建并运行”模拟器和实际设备。我还尝试从 unity 导出项目并将其导入 android studio 并以这种方式创建 apk,但结果相同。
我使用的是unity 2020.3.12f1。 我正在使用随 Unity 安装的 Android SDK 工具
C:\Program Files\Unity\2020.3.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK
我的目标是 Android 9.0 API Lebel 28
我真的不知道发生了什么。我正在使用另一个 unity firebase 包(auth 包),没有任何问题。但当我第二次尝试使用 Firestore 时,我开始收到此错误。
任何帮助将不胜感激,我已经盯着这个好几天了。
更新:
这是有关错误堆栈跟踪的更多详细信息...
06-30 06:14:09.720 32608 32638 W System.err: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/firestore_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.access$300() 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e$1.handleMessage() 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e.run() 06-30 06:14:09.721 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/firestore_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.721 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/google_api_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.722 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/app_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.722 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/app/com.paradise.casino.unity.slots-2/base.apk"],nativeLibraryDirectories=[/data/app/com.paradise.casino.unity.slots-2/lib/arm, /data/app/com.paradise.casino.unity.slots-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] 06-30 06:14:09.725 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 06-30 06:14:09.725 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.access$300() 06-30 06:14:09.725 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e$1.handleMessage() 06-30 06:14:09.726 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e.run() 06-30 06:14:09.924 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 06-30 06:14:09.924 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.access$300() 06-30 06:14:09.924 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e$1.handleMessage() 06-30 06:14:09.925 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e.run() 06-30 06:14:09.946 32608 32638 E mono-rt : at Firebase.Firestore.TransactionManagerProxy..ctor (Firebase.Firestore.FirestoreProxy) [0x00000] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\TransactionManagerProxy.cs:42 06-30 06:14:09.946 32608 32638 E mono-rt : at Firebase.Firestore.TransactionManager..ctor (Firebase.Firestore.FirebaseFirestore,Firebase.Firestore.FirestoreProxy) [0x00013] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\TransactionManager.cs:45 06-30 06:14:09.946 32608 32638 E mono-rt : at Firebase.Firestore.FirebaseFirestore..ctor (Firebase.Firestore.FirestoreProxy,Firebase.FirebaseApp) [0x00052] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\FirebaseFirestore.cs:59 06-30 06:14:09.947 32608 32638 E mono-rt : at Firebase.Firestore.FirebaseFirestore.GetInstance (Firebase.FirebaseApp) [0x00035] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\FirebaseFirestore.cs:132 06-30 06:14:09.947 32608 32638 E mono-rt : at Firebase.Firestore.FirebaseFirestore.get_DefaultInstance () [0x0000c] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\FirebaseFirestore.cs:116 06-30 06:14:09.947 32608 32638 E mono-rt : at AuthManager.Start () [0x00005] in C:\Users\myname\Documents\repos\myapp\Assets\Scripts\AuthManager.cs:56
最佳答案
这是一个bug在 Unity SDK 8.0.0 中。 我的三星 Galaxy s21 也出现同样的崩溃情况。 Google 应在下一个 firebase-firestore 版本中修复该问题。
Here is a workaround for this bug. I haven't found the root cause yet. The fix, whatever it is, may not be available for some time.
- Copy firestore_cpp_resources.zip into Assets/Plugins/Android of your Unity project.
- Change the extension from .zip to .jar (GitHub forbids attaching .jar files, probably for security reasons)
- Exit and restart the Unity Editor (not sure if this is required, but it fixed a seemingly-unrelated "duplicate import" build error for me)
- Once the fix is released make sure to delete this JAR file since it will likely conflict with future versions of the Unity SDK.
That
firestore_cpp_resources.jar
file contains the compiled QueryEventListener class that is erroneously absent from thefirestore_resources_lib.jar
that is bundled with the Firebase Unity SDK 8.0.0. By providing in via this JAR file it is able to be found and used.
关于android - 使用 firebase unity sdk firestore 包时 Android 设备上出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68153291/