I am using Firebase emulators to test my Android app. I’m trying to set up a testing environment where an Android emulator(AVD manager device) AND an android real device have access to my Firebase emulator real time database found on http://localhost:4000.
I can make both(real and virtual) devices, individually, have access to the Firebase emulator database, but NOT both at the same time.
I have my real device connected via USB port and allowed USB debugging and my Android emulator running at the same time. Then, on the Android Studio platform-tools folder I opened up a command window and input the following:
adb reverse tcp:4000 tcp:4000
This gives me an error: adb.exe: error: more than one device/emulator
Inside my firebase.json file found inside my Firebase emulator project I have the following set-up for connections to my database:
"database": {
"host": "localhost",
"port": 9000
},
How can I make both (REAL and VIRTUAL) devices or two (Virtual) devices connect to Firebase emulator Real Time data base?
2
Answers
Thank you Diego Torres Milano for pointing me in the right direction.
using the command: adb -s serialno reverse tcp:4000 tcp:4000 will work!
HOWEVER you must FIRST run the command adb devices
Once you run this command, you get all the serial no's of all the connected devices you have to ADB. Then, just run: adb -s serialno reverse tcp:4000 tcp:4000 using your desired device/emulator. It works for either real device or emulator!
You should specify the device serialno
or,
-d
and-e
if you have one of each (emulator, device).Additionally, to select the device interactively you can use this gist: https://gist.github.com/dtmilano/4537110