GithubHelp home page GithubHelp logo

emulator_test's Introduction

Firebase Emulator and Physical Android Device.

I spent a lot of time getting a physical android device to work with the firestore emulator. This repository has a working example.

The solution is to use your ip address in firebase.json

  "emulators": {
    "firestore": {
      "host":"192.168.0.199",
      "port": 8080
    },

and in your code. For me that's Flutter and Dart

FirebaseFirestore.instance.useFirestoreEmulator("192.168.0.199", 8080);

If you have questions please reach out. It took me a while to solve and I'd like to help others.

test_app

Start the emulator

cd emulator
firebase emulators:start --export-on-exit=emulatorData --import=emulatorData

Start and android emulator

emulator -avd Nexus_5X_API_28

Run the app

cd test_app
flutter run

Run the flutter app and everything should work flawlessly. Now shut down the android emulator and connect a real android device. Restart the app.

The app wont work. I get this error

W/Firestore(30266): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
W/Firestore(30266):
W/Firestore(30266): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following StateError was thrown building StreamBuilder<DocumentSnapshot<Object?>>(dirty, state:
_StreamBuilderBaseState<DocumentSnapshot<Object?>, AsyncSnapshot<DocumentSnapshot<Object?>>>#a193b):
Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist

Now if this line is commented out the physical device runs fine.

FirebaseFirestore.instance.useFirestoreEmulator("localhost", 8080);

Any help would be appreciated.

If I use more emulator services I get similar errors. this is from another app.

An Observatory debugger and profiler on Nexus 5X is available at: http://127.0.0.1:62536/y_wW9MBDpnc=/
D/vndksupport(  851): Loading /vendor/lib64/hw/[email protected] from current namespace instead of sphal namespace.
D/vndksupport(  851): Loading /vendor/lib64/hw/gralloc.msm8992.so from current namespace instead of sphal namespace.
E/flutter (  851): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [firebase_auth/unknown] com.google.firebase.FirebaseException: An internal error has occurred. [ Failed to connect to /10.0.2.2:9099 ]
E/flutter (  851): #0      MethodChannelFirebaseAuth.signInAnonymously (package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart:423:7)
W/Firestore(29632): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
W/Firestore(29632):
W/Firestore(29632): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

emulator_test's People

Contributors

bradintheusa avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.