javascript - 使用模拟器时 react native firebase 崩溃

标签 javascript java firebase react-native google-cloud-firestore

我在 react-native 项目中使用 firestore 模拟器 挣扎了几天

每当代码到达 firestore 时,应用程序崩溃而没有任何日志(RN 端)。
现在我知道 RNFirebase 已经安装好了,因为我可以访问 firestore 真实服务器。
我检查了 logcat,它给了我这个错误。

10-23 11:07:22.925  6383  6383 E AndroidRuntime: FATAL EXCEPTION: main
10-23 11:07:22.925  6383  6383 E AndroidRuntime: Process: com.test_project, PID: 6383
10-23 11:07:22.925  6383  6383 E AndroidRuntime: java.lang.RuntimeException: Internal error in Cloud Firestore (23.0.4).
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:537)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$jx84dqgUsF4ojecSMurRqFLFD1Y.run(Unknown Source:2)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:883)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:100)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:214)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7356)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
10-23 11:07:22.925  6383  6383 E AndroidRuntime: Caused by: com.google.android.gms.tasks.RuntimeExecutionException: java.lang.IllegalArgumentException: cannot find a NameResolver for http://localhost:5003
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.android.gms.tasks.zzu.getResult(com.google.android.gms:play-services-tasks@@17.2.0:15)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.remote.FirestoreChannel.lambda$runBidiStreamingRpc$0$FirestoreChannel(FirestoreChannel.java:109)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.remote.-$$Lambda$FirestoreChannel$ThFui-hvcsrVGYxlBtcTH5vVbvE.onComplete(Unknown Source:6)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.android.gms.tasks.zzj.run(com.google.android.gms:play-services-tasks@@17.2.0:4)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:232)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:919)
10-23 11:07:22.925  6383  6383 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: cannot find a NameResolver for http://localhost:5003
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at io.grpc.internal.ManagedChannelImpl.getNameResolver(ManagedChannelImpl.java:729)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at io.grpc.internal.ManagedChannelImpl.<init>(ManagedChannelImpl.java:609)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:518)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at io.grpc.android.AndroidChannelBuilder.build(AndroidChannelBuilder.java:149)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.remote.GrpcCallProvider.initChannel(GrpcCallProvider.java:130)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$initChannelTask$6$GrpcCallProvider(GrpcCallProvider.java:256)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.remote.-$$Lambda$GrpcCallProvider$SCD5iiibQ8l4haiO8ofSfE0wIJg.call(Unknown Source:2)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.android.gms.tasks.zzy.run(com.google.android.gms:play-services-tasks@@17.2.0:2)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0$ThrottledForwardingExecutor(ThrottledForwardingExecutor.java:54)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at com.google.firebase.firestore.util.-$$Lambda$ThrottledForwardingExecutor$MfIJbVuxZtLwosAgPzPA-cU66Ko.run(Unknown Source:4)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
10-23 11:07:22.925  6383  6383 E AndroidRuntime:    ... 1 more

这是我的 packages.json

  "dependencies": {
    "@react-native-firebase/app": "^12.9.3",
    "@react-native-firebase/auth": "^12.9.3",
    "@react-native-firebase/firestore": "^12.9.3",
    "react": "17.0.2",
    "react-native": "0.66.1"
  }

我有 firebase-tools v9.21.0

这是我用来调试问题的简单代码:
https://gist.github.com/jeremytrips/8cc29f7611fa34bc3cd9f7fd1157f1c0 .

我完全迷失了,因为我对 Java 一无所知。
任何帮助将不胜感激。
提前致谢
杰里米

最佳答案

Firebase 团队已在 Github thread 中得出关于此错误的结论。 :

[T]his is an error in the underlying SDK and you should try to reproduce it and log it in the underlying repo using the appropriate quickstart.

For a workaround, on the Android emulator you can't reach the local network normally. You can reach the host machine via a special IP address normally, with no extra steps. Any other use of the network external to the emulator requires adb forwards normally so that it appears to the emulator that it is connecting to the emulator host but the connection actually forwards out somewhere else. SSH port forwarding may be used also in order to bind some remote service to your local machine so the emulator may get it. In the end you will then have the emulator connecting to localhost or 10.0.2.2 (the special emulator address for emulator host) and it should work.

That is all project and network specific, there is no way we can foresee all setups. You can google for adb network forwarding, or you can run the emulator on the emulator's host machine (the normal scenario).

您可以尝试使用解决方法来访问主机。

关于javascript - 使用模拟器时 react native firebase 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69686760/

相关文章:

javascript - Angular 等待所有订阅完成

javascript - 在 javascript 中递归构建 promise 链 - 内存注意事项

java - gmail 正在修改传入邮件的 header (Message-ID)

ios - 适用于 Unity 的 Firebase SDK 无法在 iOS 中编译

JavaScript 音频对象 addEventListener canplaythrough 不适用于 IPAD Chrome

javascript - HTML5,如何将视频当前时间与标题数组匹配以在Javascript中打印标题?

java - 切换蓝牙时无限 Activity 循环

java - 如何在 select Struts2 中选择一个 HashMap 的值?

android - 从 Firebase Analytics 日志记录中排除测试设备

javascript - 如何删除超过 15 天的 Cloud Firestore 备份?