简体   繁体   English

使用 firebase unity sdk firestore package 时 android 设备出错

[英]Error on android device when using firebase unity sdk firestore package

I'm trying to use the firebase unity sdk in my android app.我正在尝试在我的 android 应用程序中使用 firebase unity sdk。 Specifically the FirebaseFirestore.unitypackage.特别是 FirebaseFirestore.unitypackage。 I can get everything working running my app directly thru unity.我可以通过 unity 直接运行我的应用程序。 But when I do an android build and deploy to my actual device or an emulator I get this error.但是当我执行 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]]

and then later down the log it says something similar...然后在日志中它说了类似的话......

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

I've attempted to "Build and Run" to an emulator and an actual device directly from unity.我试图直接从统一中“构建并运行”到模拟器和实际设备。 I've also attempted to export the project from unity and import it into android studio and create the apk that way, but it ends with same result.我还尝试从 unity 导出项目并将其导入 android studio 并以这种方式创建 apk,但结果相同。

I'm using unity 2020.3.12f1.我正在使用 unity 2020.3.12f1。 I'm using the Android SDK Tools installed with Unity我用的是 Android SDK 和Unity一起安装的工具

C:\Program Files\Unity\2020.3.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK

I am targeting Android 9.0 API Lebel 28我的目标是 Android 9.0 API Lebel 28

I'm really not sure what is going on.我真的不确定发生了什么。 I'm using another unity firebase package (the auth package) without any problems.我正在使用另一个 unity firebase package(auth 包)没有任何问题。 But the second I try to use Firestore I start getting this error.但是第二次我尝试使用 Firestore 时,我开始收到此错误。

Any help would be appreciated I've been staring at this for days.任何帮助将不胜感激 我已经盯着这个看了好几天了。

Update:更新:

here is a more details on the error stack trace...这是有关错误堆栈跟踪的更多详细信息...

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 pa 06-30 06:14:09.720 32608 32638 W System.err: java.lang.ClassNotFoundException: 在路径上找不到 class“com/google/firebase/firestore/internal/cpp/QueryEventListener”:DexPathList[[zip 文件” /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:抑制:java.lang.ClassNotFoundException:在 pa 上找不到 class“com/google/firebase/firestore/internal/cpp/QueryEventListener” th: 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 th: DexPathList[[zip 文件“/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:抑制:java.lang.ClassNotFoundException:在路径上找不到 class“com/google/firebase/firestore/internal/cpp/QueryEventListener”:DexPathList[[zip 文件”/ 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 系统.err:抑制:java.lang.ClassNotFoundException:在路径上找不到 class“com/google/firebase/firestore/internal/cpp/QueryEventListener”:DexPathList[[zip 文件“/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: 没有找到 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.路径上的“com/google/firebase/firestore/internal/cpp/QueryEventListener”:DexPathList[[zip 文件“/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 系统:错误。 at com.unity3d.player.UnityPlayer:nativeRender(Native Method) 06-30 06:14.09.725 32608 32638 W System:err.在 com.unity3d.player.UnityPlayer:nativeRender(本地方法)06-30 06:14.09.725 32608 32638 W 系统:错误。 at com.unity3d.player.UnityPlayer:access$300() 06-30 06:14.09.725 32608 32638 W System:err.在 com.unity3d.player.UnityPlayer:access$300() 06-30 06:14.09.725 32608 32638 W 系统:错误。 at com.unity3d.player.UnityPlayer$e$1:handleMessage() 06-30 06:14.09.726 32608 32638 W System:err.在 com.unity3d.player.UnityPlayer$e$1:handleMessage() 06-30 06:14.09.726 32608 32638 W 系统:错误。 at com.unity3d.player.UnityPlayer$e:run() 06-30 06:14.09.924 32608 32638 W System:err.在 com.unity3d.player.UnityPlayer$e:run() 06-30 06:14.09.924 32608 32638 W 系统:错误。 at com.unity3d.player.UnityPlayer:nativeRender(Native Method) 06-30 06:14.09.924 32608 32638 W System:err.在 com.unity3d.player.UnityPlayer:nativeRender(本地方法)06-30 06:14.09.924 32608 32638 W 系统:错误。 at com.unity3d.player.UnityPlayer:access$300() 06-30 06:14.09.924 32608 32638 W System:err.在 com.unity3d.player.UnityPlayer:access$300() 06-30 06:14.09.924 32608 32638 W 系统:错误。 at com.unity3d.player.UnityPlayer$e$1:handleMessage() 06-30 06:14.09.925 32608 32638 W System:err.在 com.unity3d.player.UnityPlayer$e$1:handleMessage() 06-30 06:14.09.925 32608 32638 W 系统:错误。 at com.unity3d.player.UnityPlayer$e:run() 06-30 06:14.09:946 32608 32638 E mono-rt.在 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.在 Firebase.Firestore.TransactionManagerProxy..ctor (Firebase.Firestore:FirestoreProxy) [0x00000] 在 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.在 Firebase.Firestore.TransactionManager..ctor (Firebase.Firestore,FirebaseFirestore.Firebase.Firestore:FirestoreProxy) [0x00013] 在 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.在 Firebase.Firestore.FirebaseFirestore..ctor (Firebase.Firestore,FirestoreProxy.Firebase:FirebaseApp) [0x00052] 在 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.在 Firebase.Firestore.FirebaseFirestore.GetInstance (Firebase:FirebaseApp) [0x00035] 在 Z.\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\FirebaseFirestore:cs:132 06-30 06:14.09:947 32608 32638 E 单室温。 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.在 Firebase.Firestore.FirebaseFirestore:get_DefaultInstance () [0x0000c] 在 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在 AuthManager:Start () [0x00005] in C.\Users\myname\Documents\repos\myapp\Assets\Scripts\AuthManager:cs:56

It's a bug in the Unity SDK 8.0.0.这是 Unity SDK 8.0.0 中的一个错误 I've the same crash on my samsung galaxy s21.我的三星 Galaxy s21 也发生了同样的崩溃。 Google should fix it in the next firebase-firestore version. 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.修复,无论它是什么,可能在一段时间内无法使用。

  1. Copy firestore_cpp_resources.zip into Assets/Plugins/Android of your Unity project.firestore_cpp_resources.zip复制到 Unity 项目的 Assets/Plugins/Android 中。
  2. Change the extension from .zip to .jar (GitHub forbids attaching .jar files, probably for security reasons)将扩展名从 .zip 更改为 .jar(GitHub 禁止附加 .jar 文件,可能是出于安全原因)
  3. Exit and restart the Unity Editor (not sure if this is required, but it fixed a seemingly-unrelated "duplicate import" build error for me)退出并重新启动 Unity 编辑器(不确定是否需要这样做,但它为我修复了一个看似无关的“重复导入”构建错误)
  4. Once the fix is released make sure to delete this JAR file since it will likely conflict with future versions of the Unity SDK.修复发布后,请确保删除此 JAR 文件,因为它可能会与 Unity SDK 的未来版本发生冲突。

That firestore_cpp_resources.jar file contains the compiled QueryEventListener class that is erroneously absent from the firestore_resources_lib.jar that is bundled with the Firebase Unity SDK 8.0.0. firestore_cpp_resources.jar文件包含已编译的QueryEventListener类,该类错误地从 Firebase Unity SDK 8.0.0 捆绑的firestore_resources_lib.jar中缺失。 By providing in via this JAR file it is able to be found and used.通过此 JAR 文件提供,可以找到并使用它。

It may be a Dex limit issue.可能是 Dex 限制问题。 Have you enabled ProGuarding at your build settings as stated at the official docs ?您是否按照官方文档中的说明在构建设置中启用了 ProGuarding?

Just update Firebase Unity SDK to 8.0.1只需更新Firebase Unity SDK到 8.0.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM