Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Stop Emulator from Command Line

This question is identical to How to shut down Android emulator via command line.

However, after attempting the suggested solution from the first answer adb emu kill has not proven successful for me.

I am automating unit tests for an android application. My bash script runs on a headless machine. It creates an android device using android create avd and executes emulator with the -no-window attribute. It then compiles the test project, connects to the emulator using adb, installs the project and executes my tests. This all works fine.

Now I need to terminate the emulator process, and just like the referenced post, I am only able to do this using kill -9.

The Google tutorial Managing AVDs from the Command Line only mentions how to stop emulators within a GUI environment.

Any help is appreciated.

like image 796
jsjrobotics Avatar asked Nov 22 '13 22:11

jsjrobotics


People also ask

How do I stop an emulator from terminal?

You could set the environment variable in the terminal window before launching a virtual device, or you could set it through your user settings in the operating system; for example, in your . bashrc file on Linux. To stop the Android Emulator, just close the emulator window.

How do I stop an instance of an emulator?

To stop a running emulator, click Menu and select Stop. To clear the data for an emulator, select Wipe Data. Or click Menu and select Wipe Data.


2 Answers

May be adb kill-server helps for you?

or

adb -s emulator-5554 emu kill, where emulator-5544 - emulator name.

For Linux users it will be

adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done

like image 192
Sergey Shustikov Avatar answered Sep 19 '22 09:09

Sergey Shustikov


To stop all running emulators we use this command:

adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done 
like image 34
uwe Avatar answered Sep 22 '22 09:09

uwe