Skip to content
Advertisement

React native firebase crashes when using emulator

I’m struggling for a few days now on using firestore emulator in a react-native project

Whenever the code reaches a firestore hit the application crash without any log (RN side).
Now I know RNFirebase is well installed as I can hit firestore real server.
I’ve checked the logcat and it gives me this error.

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

Here is my 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"
  }

And I have firebase-tools v9.21.0

Here is a simple code that I used to debug my problem:
https://gist.github.com/jeremytrips/8cc29f7611fa34bc3cd9f7fd1157f1c0.

I’m completely lost as I don’t know a thing in Java.
Any help would really be appreciated.
Thanks in advance
Jeremy

Advertisement

Answer

The Firebase team has concluded about this error in a 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).

You can try using the workaround in order to reach the host machine.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement