zsh script that lists emualtor, runs it, then installs react native app

31 Views Asked by At

I am trying to start an Android emulator command line that works fine, but it never goes to the npx react-native run-android line from the script after it is loaded. Is there something I need to do?

    emulator -list-avds

    # Ask the user if they want to run the app on the simulator
    read -p "Which Android emulator name (i.e. Pixel_7_Pro_API_34)?: " device

    emulator -avd $device

    npx react-native run-android
1

There are 1 best solutions below

0
Lino On

One option might be to launch the selected emulator in background, wait for it to start and then execute the npx command. The final script will be like the following:

emulator -list-avds

# Ask the user if they want to run the app on the simulator
read -p "Which Android emulator name (i.e. Pixel_7_Pro_API_34)?:" device

emulator -avd $device &

adb wait-for-device

npx react-native run-android

hope this helps