简体   繁体   中英

React Native run on multiple simultaneous Android emulators

I would like to test my app on at least 2 Android emulators simultaneously. I can start 2 emulators but can't seem to find how to react-native run-android my app on 2 emulators with ADB. If possible I would also like to be able to run a react-native log-android on each one while testing my app.

Is there a way to do so ?

Only you can run different ports. Because one port one listener :/
Solve :

react-native start --port 9988
./emulator -port 9988 -avd devicename1

react-native start --port 9999
./emulator -port 9999 -avd devicename2

Edit2:

Before run emulator , You can write terminal then run.

function emulator { cd "$(dirname "$(which emulator)")" && ./emulator "$@"; }

First emulator is react .

emulator -port 9988 @react
react-native run-android ( automaticaly detect emulator )

Second emulator is r .

emulator -port 8081 @r
react-native run-android (automaticaly detect emulator )

在此处输入图片说明

In order to run your react application on multiple emulators, just start 2 emulators as usual and then use the command react-native run-android .

You can even specify any port number as react-native run-android --port 8084 if you want. Your app will start on both the emulators simultaneously. :)

Have a look here

The accepted answer by @Burhan Yılmaz did NOT work for me. This is probably due to new updates and development in the relevant software. The following steps demonstrate what worked for me.

  1. Start the 1st emulator, eg emulator -avd Nexus_S_API_28

  2. Start the 2nd emulator, eg emulator -avd Nexus_S_API_28_2

  3. Start React-Native in the same way, which you would usually use (without specifying any ports.) react-native run-android

This sends a copy of the code to both devices. However, each device runs its copy in isolation from the other device.

Environment Details:

  • MS Windows 10
  • Android SDK 29.0.2
  • React-Native: 0.61.2

使用Genymotion ,你只需要启动 2 个实例并启动它们,就好像只有一个一样( react-native run-android安装应用程序和react-native start

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM