46

The emulator starts up fine. But when you long-press the power button (or F7) and choose "Power off", it displays a "Shutting down" message which remains on-screen forever and the emulator won't actually shut down.

I can close the emulator window or kill its process. But I'm wondering if this is the correct way to shut down an Android emulator.

Cyker
  • 9,946
  • 8
  • 65
  • 93
  • 1
    It's just an emulator; closing the window isn't going to cause permanent damage. Worst case, you have to reset the emulator. – nneonneo Oct 26 '12 at 00:25
  • @nneonneo So there are no better solutions? Have you ever encountered the same problem? Whether it's a bug or not... – Cyker Oct 26 '12 at 03:40

17 Answers17

36

According to the documentation I found at google, simply closing the emulator window is the correct way to shut the emulator down.

To stop an emulator instance, just close the emulator's window.

Source: Starting and Stopping the Emulator

fhw72
  • 1,066
  • 1
  • 11
  • 19
  • Worked for me! To restart the emulator, do not run your application again, but do it from the run configuration, where you can choose the emulator: just choose your emulator and press "start". – Gari BN Jan 23 '14 at 14:58
  • 14
    Sorry, the documentation lies. The window doesn't even have a "close" button. – wvxvw Dec 12 '16 at 23:19
  • 2
    All though it still says to shut it down, close the window, the process still runs in the background hogging memory as it is still open – Zoe Dec 30 '16 at 18:08
  • @Zoe - if the window closes successfully, a process that uses a lot of memory should go away. There may be a second, smaller process, that might remain behind. Examine what processes are created when you first run the emulator. – ToolmakerSteve Oct 29 '18 at 19:06
  • 1
    Closing the emulator window causes the emulator's state to be saved. Upon relaunching the emulator it will restore to the state of trying to shut down. – David Baucum Dec 07 '20 at 19:05
  • 2
    Closing the window only stops the emulator for me if window is docked, not the emulator is running in a separate window (in windows), obtained by changing ViewMode in AndroidStudio on the emulator. So to stop it I change it back to docked, or kill the process – arberg Mar 10 '22 at 14:14
30
  1. Open Android Studio
  2. Go AVD Manager
  3. Go Actions Tab
  4. Click arrow
  5. You will see stop
  6. Click and emulator shut down :)

If the device is stopped in a bad state, this may persist when relaunching the emulator. To get around this, simply select 'Cold Boot Now' from the virtual device's drop down menu in the manager.

ninehundreds
  • 1,097
  • 2
  • 21
  • 43
kablanfatih
  • 473
  • 4
  • 14
  • 2
    Thank you! My AVD was stuck shutting down and this forced it! – Abushawish Oct 18 '19 at 17:59
  • 4
    Stopping the emulator and then choosing "Cold Boot Now" from the AVD Manage is the solution that works. – David Baucum Dec 07 '20 at 19:06
  • This mostly worked but the virtual device was still in a bad state. So I had to delete the device folder manually in the Windows users avd directory as the AVD Manager app could not delete it (error message). – Meliovation Apr 28 '21 at 17:15
  • 4
    It appears there is no stop option anymore, [this answer](https://stackoverflow.com/a/14813613/1089267) was the solution! – thinkOfaNumber Apr 08 '22 at 01:14
  • 1
    There is no "stop" after clicking the arrow. The only way to stop the emulator is to quit the studio. Yet another Google's "improvement" to the dying platform – Oleg Gryb Feb 25 '23 at 21:08
12

I'm running Android Studio Chipmunk 2021.2.1 and most of the solutions in this thread no longer work.

adb solution

What does work is using adb to shutdown the emulated device:

adb reboot -p

(The -p stands for power off, so it's not really a "reboot")

If you have multiple devices attached you'll need to specify which one:

adb -s DEVICE_SERIAL reboot -p

(You can find the list of device serial numbers by running adb devices)

Alternate pkill solution

Shutting down via adb is the clean way to shutdown the device. If for some reason that doesn't work, you can kill the emulator by running:

pkill qemu

This will kill every running instance of QEMU on your computer (QEMU is what the Android Emulator uses under-the-hood). pkill(1) is installed on most computers, but you may have to install it if it's not built-in.

Michael Kropat
  • 14,557
  • 12
  • 70
  • 91
  • where can you find the device serial number in the emulator settings so we can match it with the one from printing it out? – Logan Cundiff Aug 23 '22 at 16:07
  • There's probably a better way to do it, but I stop all emulators and disconnect all devices, then start the one I want to find the id for, then run `adb devices`. Since only 1 shows up you know that's the serial you want. – Michael Kropat Aug 26 '22 at 14:20
  • 'pkill qemu' is the only one that works except studio restart of course. @Google - that's ugly! – Oleg Gryb Feb 25 '23 at 21:13
10

Okay so do this:

  1. Open Android Studio Android Studio

2.Go to AVD Manager AVD Manager Select

3.Select Your Emulator and Cold Boot Now enter image description here

saif aly
  • 545
  • 7
  • 8
6

On Mac, you can simply use the shortcut Cmd + w to close the emulator window (either window or docked mode). It would automatically shut down the emulator.

I've verified this for Android Studio Bumblebee | 2021.1.1 Patch 3

Praveen Singh
  • 2,499
  • 3
  • 19
  • 29
5

Open Virtual Device Manager, locate the virtual device you are concerning, check "Cold Boot Now" on the drop down menu of actions column of it.

Jonas Chen
  • 51
  • 1
  • 2
  • 2
    This will *restart* the emulator, performing a cold boot. The question asked here is how to *shut it down* (without starting it up again). – ToolmakerSteve Oct 29 '18 at 19:00
3

if you are using last version at Android Studio.

Deleted this file.

snapshot.lock.lock

multiinstance.lock

hardware-qemu.uni.loc

from

.android/avd/Pixel_3a_API_29.avd
  • Deleting the lock file will unblock you from re-running a new instance of the emulator. But this doesn't shutdown the old emulator instance, right? Which is likely to lead to other problems when you try to run more than 1 instance of the same AVD at the same time. – Michael Kropat Jun 29 '22 at 19:58
  • i can't remember, this problem solved long time ago, maybe you're right. But this process is worked for my project but thank your this comment. – Berkay Nayman Jun 30 '22 at 09:47
3

On Windows 11, the emulator often refuses to shutdown, and just stays frozen. Killing the qemu-system process in Task Manager while AndroidStudio is running resolves the issue.

fordcars
  • 457
  • 3
  • 14
  • This worked for me and I'm using Windows 11. Other solutions on this page didn't work. I think you might be right that this is something new and special for Windows 11. – steve May 07 '23 at 14:32
  • Thanks. Works on Mac as well, when stopping the qemu-system process from Activity Monitor app. – shbedev Jul 02 '23 at 11:27
3

Step 1: Open Running Emulator from Android Studio. It looks like the following image: enter image description here

Step 2: Pull the notification bar from top. enter image description here

Step 3: You'll see power options at the right bottom of the screen. Click on power icon. -> select shut down option.

1

This is for Mac Users.

  1. Click on android emulator.
  2. Go to top menu
  3. Click on item which is shown (there will only be one)
  4. Click on Stop/Quit from the dropdown.

It will then save its present state and then it will shut down.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

No idea

I really don't know.

Here's what I do know.

Getting a list of running Android instances

You can get a list of running Android instances by entering this command:

adb devices

What else you can try

Now you can visit "How I shutdown Android phone with adb command?" and try all the proposed solutions.

I don't know whether any of them work. Please leave a comment below and inform us.

More thoughts

You can connect to a running emulator by entering this command:

adb shell

Now you can enter Unix-like shell commands which will do things. These are similar to the usual Linux shell commands.

Maybe the following will work? But, does it truly shut down, or does it reboot?

sync && reboot -p

In fact, does any "shut down" command work, or do they all just cause the running Android instance to reboot?

Please file a bug report

Someone should file a bug report, in the Android issue tracker, against the current version of the Android emulator — plus one of Google's newest available emulator ROMs. Once you do so, please leave a comment below and provide us with a link to the bug report.

Community
  • 1
  • 1
  • 1
    Answering someone's question with "No idea" is not helpful. If you don't know the answer then don't answer. – David Baucum Dec 07 '20 at 19:06
  • That reboot command... it should be just "reboot -p" and it worked for me. Thanks :D – Xonshiz Dec 28 '20 at 05:15
  • `adb reboot -p` is the correct solution in 2022. I started to edit this answer, but ended up deleting like 90% of it and adding a bunch of different stuff, so I reconsidered and made a separate answer instead: https://stackoverflow.com/a/72821966/27581 – Michael Kropat Jun 30 '22 at 21:01
0

If you were taking advantage of the emulator's "snapshot" feature, you probably didn't need to shut Android down in the first place.

If the feature is enabled, closing the emulator window should hibernate the emulator's state to disk. (Source.) This should make the emulator start up quicker next time.

You can enable snapshot support using AVD Manager's "Edit..." button.

If you want to enable snapshot support, you'll probably need to disable the "Use Host GPU" feature. I believe that the two features are mutually incompatible.

Community
  • 1
  • 1
0

I tried to hold click on right side button for 3-5 seconds and choose to turn it off. It works for me.

TheBosti
  • 1,354
  • 13
  • 19
  • Weirdly this doesn't work for me anymore—it pops up some Google assistance thing—even though it had been working for me for years – Michael Kropat Jun 30 '22 at 21:03
0

Found an easy solution: from android device manager-> when having emulator in question highlighted, click on ... (three dots) on top right-> select Start with factory defaults.

0
  • Goto AVD manager (Tools menu > AVD Manager), in the actions section, stop and then wipe data
  • Now click play button in the same window
Hazrat Ali
  • 21
  • 2
0

AVD is running on port 5555, the easiest way to close it is using the below command line:

sudo lsof -n -i :5555

It will show the PID that is running your AVD, use -9 or -15 to kill the process

kill -9 [PID]

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
0

It wasn't even let me wipe data or do any action as it kept on running and the pause emulator button wouldn't even be interactable. So here's what i did

  • I click the three dots in avd manager of the emular and clicked show on disk.
  • I just deleted the folder and file of its name 1 each.

And it worked like a charm.