Android emulator won't shut down - android

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.

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

Open Android Studio
Go AVD Manager
Go Actions Tab
Click arrow
You will see stop
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.

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.

Okay so do this:
Open Android Studio
2.Go to AVD Manager
3.Select Your Emulator and Cold Boot Now

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

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.

This is for Mac Users.
Click on android emulator.
Go to top menu
Click on item which is shown (there will only be one)
Click on Stop/Quit from the dropdown.
It will then save its present state and then it will shut down.

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.

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.

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

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.

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

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]

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.

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

Related

Android studio doesn't recognize the running emulator

When I run my app from AndroidStudio 0.4.3 using Run I see Choose Device which has two sections choose a running device or Launch Emulator. I don't have a running emulator at the moment so I click the ... to launch AVD manager and start an emulator. At this point I see that under choose a running device the emulator I just launched shows up but its listed as offline.
In the past the offline status went away when the emulator was fully up and running. However, now I've noticed that when the emulator is launched fully, it no longer appears in choose a running device.
I feel like I'm always playing cat and mouse game with android studio picking up the emulator. Is there a better way to do this? Am I missing something?
Disable and then Enable ADB Integration
In Android Studio go to
Menu -> Tools
Android
Enable ADB Integration (should be checked, click to remove check)
Enable ADB Integration (should not be checked, click to add check)
Run your app again. Emulator that was previously missing from Run dialog should be available to be selected upon which to run your app.
Try to kill the adb server and restart it.
Locate your adb binary (linux/osx) or adb.exe (windows) and do:
adb kill-server
adb start-server
this should fix your problem
Even if your problem still not solved then Restart emulator.
Wipe Data and restarting emulator helped me, hope this helps to someone.
inside AVD manager, select your virtual devices, then 1 stop, 2 wipe user data, 3 cold reboot, works for me.
On Windows, running Android Studio with administrator permissions can help (in addition to restarting adb server).
Unchecking the "Enable ADB " worked for me
In Android Studio Arctic Fox (2020.3.1) it helped me to cold boot the device.
add -port 5037 on ../[some_emulator]/emu-launch-params.txt file & try again...
like image

Incompatible Android emulator running in background

I am Using the latest Android SDK in my Win 7. But whenever I try to launch my any android projects it shows the following window :
I have checked the .android/avd/ folder but there are only 3 avds there. What is wrong with the AVD or anything wrong in my work.
Do you actually have an AVD instance running? If so, have you tried clicking OK when you hit that screen?
If you don't have an AVD running, have you tried restarting Eclipse/AVD Manager/your machine?
This dialog is indicating that you have an AVD running already. It's basically prompting you to select an AVD to send the app to. At least in my setup, selecting OK at this screen should run the app in the active AVD.
Try adb tcpip 5554. This will restart your ADB listening to the port 5554. The entry will go away.

'adb devices' showing dummy device

I have been facing this problem for quite sometime now. Running 'adb devices' shows me an additional dummy device although its named as emulator-5554. FYI, I don't have any emulator running as well.
adb devices
List of devices attached:
xxxxxxx device (Actual device)
emulator-5554 device (Dummy thingy shown as device).
How do I clean up this mess?
Same problem for me but I don't see any Bluestacks service in my services list. after
adb devices shows emulators I didn't have, I usually just type the command
adb kill-server
and running the
adb devices
once more shows only the devices that are connected.
I had the same issue. I did this and now everything is ok
click Windows+R
type services.msc
stop BlueStacks Android Service
I have figured out the issue. I had installed Bluestacks for Mac for trying out Android apps on Mac. This was running an emulator with a different name.
Figured it out by taking a screenshot of the emulator and it showed the launch screen of Bluestacks. Uninstalled Bluestacks and all is well now.
the adb server is scanning for emulators on all even local ports from 5555 to 5555+128 (5683). If you have a custom service which use one of these ports... You are stuck with the "adb -d command" requirement
pls check in task manager whether emulator-arm.exe is running. If so, try stopping both adb.exe and emulator-arm.exe
I had the same problem and non of these answers helped. So I figured out that my system didn't shut down properly and that's the reason I have a dummy emulator-5554. The solution was to create a new emulator with a name then launch it? While it's launching kill the server using cmd until when the emulator powers on and you can see its name under Devices in DDMS. After this shut the emulator...emulator-5554 is gone, Now you can start Bluestacks and connect
I was facing the same issue, and that due to BlueStacks too. In case you have Windows and you don't want to remove it, then you can stop its service "BlueStacks Android Service."
To do that click Windows+R, type services.msc then stop "BlueStacks Android Service"
Reference:
http://forum.xda-developers.com/showthread.php?t=2612389
Eclipse emulator NOT BlueStacks:
In the case of the eclipse emulator running in the background and you don't know how to close it, just go to devices tab and choose the dropdown menu on the right, then Reset adb. OR, just reset the adb using adb console.
Just open task manager and end task bluestacks
I also meet the same problem.Here is my answer to solve this problem.
in Windows system.
1.in cmd terminal,usr cmd netstat -aon|findstr "5555"
2.use cmd tasklist|find "PID",the PID para should be a process number which is the result of the first step .
3.changed the Port No. to other ,which should not be "5555"
That's done.
After trying:
adb kill-server
stopping adb.exe in task manager
adb usb
and a few other stuff I can't even remember. . .
I restarted my computer and the dummy-device was gone!

Android Emulator starts but Eclipse doesn't recognize it

As a general rule, everything works fine, but then sometimes either Eclipse or my Android emulator decides to be a jerk and refuses to work.
I open the AVD Manager in Eclipse. I choose which AVD I want and click Start. The emulator starts up and it goes through the loooong process of booting. It finally finishes booting and then for some reason, it immediately reboots and goes through the looong process of booting again. Once it boots the second time, Eclipse loses track of it. It is no longer lists in the Devices tab and I can't install my app or run it on that emulator. If I kill the emulator and try to start it over, then I get the exact same behavior. It's incredibly frustrating.
There are no messages happening in the console to explain the behavior. Any idea why this is happening?
That's a known issue when adb starts before the emulator. I don't know the real reason, but a quick workaround is to restart adb in the command prompt (with the emulator running)
> adb kill-server
> adb start-server
Now,
> adb devices
will return the emulator and Eclipse will be able to install the app.
While in Eclipse, choose Window->Show View->Devices.
If you can't see the emulator on the newly opened window choose the down-arrow icon in the same window (near the minimize and maximize buttons) and from the dropdown menu select "Reset ADB".
The alternative is to open CMD.exe and type the following two commands (change the ADB directory as necessary):
C:\Program Files\Android\android-sdk\platform-tools\adb.exe kill-server
C:\Program Files\Android\android-sdk\platform-tools\adb.exe start-server
I've seen this too. If you kill and restart the adb server, Eclipse should then see it.
> ./adb kill-server
> ./adb start-server
tried these commands in mac os x / eclipse - works, but it also kills the actual devices and you have to unplug/plug them back in to get them back.

How to attach back the Android emulator to ADB?

After I start the emulator by hitting Debug in Eclipse, after certain time it disconnects from the ADB, but the emulator stays open. It is responsive, I can navigate and start apps.
How can I attach back the emulator to ADB, to be able to debug from Eclipse?
(the current workaround is the terminate the emulator, close Eclipse and restart both of them, which takes 10 minutes as you know the emulator needs time to start up)
EDIT 1
Check out this image:
EDIT 2
After I kill and restart server. One emulator process shows up in Devices tab in Eclipse. But that cannot be expanded, and I don't see sub-processes.
I can't hit debug already, as it says: Debug already running. (How to I stop the debug?)
If I managed to start the debugging of another project, It hangs out in the emulator telling me: Waiting for the debugger to attach. Nothing happens.
As you said, the problem is not Eclipse losing contact with the Emulator, but ADB - the Android Debug Bridge - losing contact with it. As Eclipse uses ADB to communicate with the emulator when ADB is broken Eclipse can do nothing.
To fix this stop the ADB server by running the following command:
adb kill-server
Eclipse will then usually try to restart ADB, or you can restart it yourself by running an ADB command, such as:
adb devices
If you do, you'll see output like this:
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
emulator-5554 device
You can also do this via the mouse, using the Reset adb option in the Devices view in Eclipse.
It's also worth noting the Console view has two modes, DDMS and Android. You're usually in Console mode but it's DDMS mode which will show ADB status messages. Select modes by clicking the button with the Monitor icon, or using the arrow next to it:
If all else fails, try killing the adb processes from the OS. On Windows XP I use:
TASKKILL /F /IM adb.exe
There is an easier way. From eclipse you can reset the adb from DDMS panel.
Here's a short video on doing that "Reset ADB on DDMS"
Here's a quick screenshot of where you can get the option.
Sometimes a kill-server won't help at my machine (WinXP). For example I can't see the emulator in the DDMS-View any more or I do see it but no processes running on it.
In these cases I close the emulator and eclipse and manually kill the adb.exe-process from the process list.
When I then restart eclipse and the emulator, everything's fine again.
Now I just need a keyboard-shortcut for that :-)
on a mac, i just had to kill adb from activity manager and manually re-open the program again. had eclipse open all through and it worked just fine.
Try with adb kill-server and adb start-server. Even then the same problem occurs kill your running process from ddms prespective. Refer this link(http://www.jiahaoliuliu.com/2011/02/stopping-android-applications-already.html). This solved my issue. Hope for you also.
I am testing an application on an Android 4.0 (API level 14) emulator and once I run the app the emulator starts up and as soon as it loads, Eclipse DDMS disconnects from the emulator.
Here is the workaround that I am using: Open terminal, navigate to platform tools (C:\android-sdk\platform-tools\ or wherever you have your android-sdk installed), and run adb kill-server, and then run, adb start-server. DDMS should now list the emulator - from Java perspective, right click on the app -> Run As -> Android Application.
Hope this helps.
My handy bash script
#!/bin/bash
./path/to/adb kill-server
./path/to/adb start-server
./path/to/adb devices

Categories

Resources