I started an Android emulator using the following shell command:
emulator -avd TEST_AVD
The emulator starts just fine, but the shell script never finishes executing. It just hangs there even after the emulator has completed startup. I have tried with a number of other arguments that I could find, but nothing could quite do what I want it to. How do I know, or stop the shell command, when the emulator is ready to go?
I am setting up our Jenkins CI to use a Jenkinsfile to start the emulator, and then run a series of gradle commands. In short, I'd like to do this:
sh "emulator -avd TEST_AVD" sh "./gradlew clean test spoon"
However, I don't want to run the gradle tasks until the emulator has finished startup, and I can't figure out how to do that in the terminal.
wait-for-device can be specified after adb to ensure that the command will run once the device is connected. -s can be used to send the commands to a specific device when multiple are connected.
Use the emulator command to start the emulator, as an alternative to running your project or starting it through the AVD Manager. Here's the basic command-line syntax for starting a virtual device from a terminal prompt: emulator -avd avd_name [ {- option [ value ]} … ]
If the emulator fails to launch due to the error vulkan-1. dll cannot be found , you probably need to update the emulator. To update the emulator in Android Studio, go to Tools > SDK Manager and install the latest stable version of Android platform.
If you want to do something after you start the emulator you should start it in the background
emulator -avd TEST_AVD & adb wait-for-device # other stuff here
adb
can wait for a device over a transport to be in a particular state
adb wait-for[-<transport>]-<state> - wait for device to be in the given state: device, recovery, sideload, or bootloader Transport is: usb, local or any [default=any]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With