How to run multiple emulators with Expo

I’m trying to run multiple instances of Expo on multiple emulators, similar to the request mentioned on this Expo github thread

I see the dev who requested this also created a branch here for it, but it seems to have never been merged…

Does anyone know a way to get this working? I’m on a windows machine, and the only other workarounds I’ve read are for Mac.

This would be a really useful feature IMO. Currently I need it to test a chat feature and want to have several devices loading the dev environment: each one will log in as a different user, and each one will then write messages to the DB that I should be able to see reflected on the relevant emulators.

But there are surely multiple other use-cases.

Hi @cmadden

The workaround mentioned in that issue looks like it should work fine on Windows, Mac or Linux. You just need to have a copy of emulator and adb, preferably in your PATH. These both come with the Android SDK.

e.g. I have them at:

Android/Sdk/emulator/emulator
Android/Sdk/platform-tools/adb

Step 2 might trip you up on Windows:

$ ~/Android/Sdk/emulator/emulator -avd Pixel_2_API_30 &
$ ~/Android/Sdk/emulator/emulator -avd Pixel_3a_API_30 &

On Linux or Mac the “&” will cause the command to run in the background. In Windows you should leave out the “&” and you might need to run each command in a separate terminal window.
If the emulator command is in your PATH, you can just run:

C:\> emulator -avd Pixel_2_API_30

etc.

Similarly, if adb is in your PATH you’d run something like this:

C:\> adb devices
C:\> adb -s emulator-5554 shell am start -a android.intent.action.VIEW -d exp://192.168.43.174:19000
C:\> adb -s emulator-5556 shell am start -a android.intent.action.VIEW -d exp://192.168.43.174:19000

Apparently you can use the Windows “START” command to get something similar to the Unix “&”.

So, you could try something like the following (I have not tested it):

C:\> start /B emulator -avd Pixel_2_API_30 >Pixel_2.log
C:\> start /B emulator -avd Pixel_3a_API_30 >Pixel_3a.log

Thanks for the tips @wodin - I just got around to trying this now.

I can confirm the adb devices command works to list any devices.

emulator -avd Pixel_2_API_30 also works to start up one of the emulators.

But even after running expo start, the final command fails. eg:

adb -s emulator-5554 shell am start -a android.intent.action.VIEW -d exp://192.168.43.174:19000

Error is Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=exp://192.168.0.100:19000 flg=0x10000000 }

It’s actually the same error as the one listed here: Error running adb: Error running app. Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=exp://192.168.0.100:19000 flg=0x10000000 } · Issue #398 · expo/create-react-native-app · GitHub

I’m going to try a few more options when I get the time, and if any work I’ll post them here for future ref.

1 Like