繁体   English   中英

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

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

我正在尝试在我的 android 应用程序中使用 firebase unity sdk。 特别是 FirebaseFirestore.unitypackage。 我可以通过 unity 直接运行我的应用程序。 但是当我执行 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 导出项目并将其导入 android studio 并以这种方式创建 apk,但结果相同。

我正在使用 unity 2020.3.12f1。 我用的是 Android SDK 和Unity一起安装的工具

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

我的目标是 Android 9.0 API Lebel 28

我真的不确定发生了什么。 我正在使用另一个 unity firebase package(auth 包)没有任何问题。 但是第二次我尝试使用 Firestore 时,我开始收到此错误。

任何帮助将不胜感激 我已经盯着这个看了好几天了。

更新:

这是有关错误堆栈跟踪的更多详细信息...

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 文件“/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”: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 系统:错误。 在 com.unity3d.player.UnityPlayer:nativeRender(本地方法)06-30 06:14.09.725 32608 32638 W 系统:错误。 在 com.unity3d.player.UnityPlayer:access$300() 06-30 06:14.09.725 32608 32638 W 系统:错误。 在 com.unity3d.player.UnityPlayer$e$1:handleMessage() 06-30 06:14.09.726 32608 32638 W 系统:错误。 在 com.unity3d.player.UnityPlayer$e:run() 06-30 06:14.09.924 32608 32638 W 系统:错误。 在 com.unity3d.player.UnityPlayer:nativeRender(本地方法)06-30 06:14.09.924 32608 32638 W 系统:错误。 在 com.unity3d.player.UnityPlayer:access$300() 06-30 06:14.09.924 32608 32638 W 系统:错误。 在 com.unity3d.player.UnityPlayer$e$1:handleMessage() 06-30 06:14.09.925 32608 32638 W 系统:错误。 在 com.unity3d.player.UnityPlayer$e:run() 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。 在 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。 在 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。 在 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 单室温。 在 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。 在 AuthManager:Start () [0x00005] in C.\Users\myname\Documents\repos\myapp\Assets\Scripts\AuthManager:cs:56

这是 Unity SDK 8.0.0 中的一个错误 我的三星 Galaxy s21 也发生了同样的崩溃。 Google 应该在下一个firebase-firestore版本中修复它。

这是此错误的解决方法。 我还没有找到根本原因。 修复,无论它是什么,可能在一段时间内无法使用。

  1. firestore_cpp_resources.zip复制到 Unity 项目的 Assets/Plugins/Android 中。
  2. 将扩展名从 .zip 更改为 .jar(GitHub 禁止附加 .jar 文件,可能是出于安全原因)
  3. 退出并重新启动 Unity 编辑器(不确定是否需要这样做,但它为我修复了一个看似无关的“重复导入”构建错误)
  4. 修复发布后,请确保删除此 JAR 文件,因为它可能会与 Unity SDK 的未来版本发生冲突。

firestore_cpp_resources.jar文件包含已编译的QueryEventListener类,该类错误地从 Firebase Unity SDK 8.0.0 捆绑的firestore_resources_lib.jar中缺失。 通过此 JAR 文件提供,可以找到并使用它。

可能是 Dex 限制问题。 您是否按照官方文档中的说明在构建设置中启用了 ProGuarding?

只需更新Firebase Unity SDK到 8.0.1

暂无
暂无

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

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