Carven
Carven

Reputation: 15660

How to get android emulator and device running in tandem?

I have gotten my android device connected to my dev machine (Windows) and react native is able to send the app to my device when I run the run-android command. However, it seems like when I have both the emulator running and the device connected, only the emulator will work with the RN JS server.

For my device to work, I have to close my android emulator. And both the android emulator and my device seem to run independently of each other.

How can I have both the emulator and my device run my RN app in tandem like they are the same device except that one is on my computer screen and the other is on the device screen? So, it will be like when I reload in the emulator, the device gets reloaded too. And when I tap on something in my RN app on the device, this interaction is also reflected in the emulator and vice versa. In other words, it's almost like the emulator is actually the actual device.

Upvotes: 0

Views: 3402

Answers (2)

Vigneshkumar
Vigneshkumar

Reputation: 52

You can use this react-native run-android --deviceId xxxxxx

Upvotes: 0

Eldelshell
Eldelshell

Reputation: 6950

You can use the --deviceId flag with run-android.

$ react-native run-android --deviceId emulator-5554

What I'm not so sure is if react-native start will work with both devices at the same time.

Edit:

After reading the source code I've found there's a --variant flag which seems to do what you want without having to specify any device.

Upvotes: 1

Related Questions