I added one more android emulator for react native 0.59 app test. I am able to launch 2 emulators. The adb devices
command has the following output:
List of devices attached
emulator-5554 device
emulator-5556 device
When there is one emulator, I use on cmd terminal to do react-native run-android
and another one to do react-native log-android
. The backend server is running on the same PC. Here is the virtual devices in android studio:
What I would like to do is to launch 2 app representing 2 users connecting to the backend at the same time for testing. I tried to launched one app when 2 emulators are running and the loading of the app is extremely slow. It seems that the 2 app need to be launched on 2 different ports and the solutions I found online seems not working here. Also react-native log-android
throws error when encountering 2 emulators.
You can run multiple emulators at the same time simply by running your app again. When the AVD manager pops up, instead of selecting your already running emulator, click 'Launch Emulator' and select another emulator to launch. Thank you for the answer!
You can run multiple android device emulators (Create Multiple Device Definitions. Check.) You can run more than one emulator. (You can launch more than one at a time by multi-selecting in the Run option.
Try running the metro-bundler
at 2 different ports. Open up one terminal in you project root and use the default command as below,
react-native start
This starts one server at port 8081 default.
And in another terminal run
react-native start --port=9090
This starts another server at port 9090
Now in a third terminal run
react-native run-android
This will compile and start the apps in both your running emulators at default port.
When the apps start up properly, select one emulator and open up the dev menu using Ctrl+M
.
Click Dev Settings button at the bottom.
Click Debug server host & port for device button.
Type localhost:9090 or ip_address:9090 and click OK button
Reload the app and it will fetch the js bundle from your react-native server
running at 9090 port
log-android
from react-native
CLI is simply using adb logcat
to show the Android logs.
adb
has a -s
parameter that lets you specify the emulator serial. First you'll need to list the currently open devices using adb devices
. You'll get a list, for example:
List of devices attached
emulator-5554 device
Now you can specify the specific device:
adb -s emulator-5554 logcat *:S ReactNative:V ReactNativeJS:V
You can run it multiple times for all of the running devices that you wish to see logs for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With