Skip to content

run-android with specified emulator name #1038

@jayu

Description

@jayu

Describe the Feature

be able to run react-native run-android --emulator MyEmulatorName

After shipping #676 we are able to start an android emulator during run-android.
Cli will start a new emulator if there isn't any device available. The drawback of the current solution is that it tries to start the first emulator from the list returned by emulator -list-avds. It would be usefull to be able to run the app on a specific emulator, even if there are other devices connected. It could work similarly to the deviceId flag. We could add an emulator flag followed with the emulator name.

Possible Implementations

This implementation has several edge cases worth discussing, but we will need the following to achieve the goal

Get the emulator names based on deviceId

  1. use adb.getDevices implemented in run-android to get list of currently running devices
  2. Look for deviceIds with pattern emulator-PORT_NUMBER
  3. Map found deviceIds to emulator names using adb -s emulator-PORT_NUMBER emu avd name

Modify tryLauchEmulator to accept the emulator name as a param

Then if an emulator is running, launch the app using tryLaunchAppOnDevice
If the emulator is not running, lunch it and then check once again for adb.devices to get it's deviceId, then tryLaunchAppOnDevice

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions