I want to check if all the emulators has booted successfully. I have tried with this command adb shell getprop sys.boot_completed this works if i am running one emulator. But if i have more than one emulator this command returns error as following: error: more than one device/emulator.How to solve this?
You should specify the device serial number on the adb command line to let it know which one you want to interact with.
Something like
adb -s emulator-5554 shell ...
Also, if you are doing it from the command line, multiple times and you are starting to be annoyed by that, you can try https://gist.github.com/dtmilano/4537110 which allows you to select the device
$ adb shell
1) 02783201431feeee device 3) emulator-5554
2) 3832380FA5F30000 device 4) emulator-5556
Select the device to use, <Q> to quit: 1
$
I've created a couple of AVD-s in Android Studio. They were launching on emulator port 5554. Then I've created another AVD via android avd application, and they are starting on port 5556.
Now with a single emulator running, I get the following output from adb devices -l:
List of devices attached
emulator-5556 device
emulator-5554 offline
I'm using the tooling which cannot supply the -s (specific device) option to adb, so when trying to install an app, I get an error:
error: more than one device/emulator
And I'd like that there be a single connected emulator: the only one that I'm running.
I thought that removing the old Android Studio-created devices would do the trick of removing the emulator-5554, but nope. Even new devices created in Studio will open on 5556. So I've ended up with a forever-offline zombie emulator-5554 that screws up my build tooling.
How can I force the new emulators to be run on port 5554 and/or remove the offline emulator-5554?
(Running Ubuntu 16.04 if it matters.)
When I am facing the same issues than doing like below:
Restart adb by issuing adb kill-server followed by adb start-server in a command prompt
Disable and re-enable USB debugging on the phone
Rebooting the phone if it still doesn't work.
99% of my issues have been resolved with these steps.
I have this problem on MacOS and solved it by
Open the Spotlight search: Press Command + Spacebar
Type Activity Monitor
Open the Activity Monitor
Search for qemu
Force quit the qemu process
Restarting adb like an answer above did not help.
This is an often thing that happens, follow this steps:
Windows+R
type services.msc
stop BlueStacks Android Service
I couldn't find BlueStack on services but I manage to get it solved by 'end task' on Task Manager under Processes.
Weirdly, the only way I've been able to solve this has been by restarting my computer (sometimes twice).
** SOLVED **
https://github.com/freeload101/SCRIPTS/blob/5295f2b96581917c09ade309f91a7c46be370b7e/Windows_Batch/Android_Debloat_N_Dump.bat#L53
echo [+] %date% %time% INFO: Trying to find and kill processes on port 5563 that will break adb
FOR /F "tokens=5 " %%A in ('netstat -ano ^| findstr :5563') do (
echo [+] %date% %time% INFO: Killing process PID "%%A"
taskkill /PID %%A /F
)
echo [+] %date% %time% INFO: Killing any existing adb server
"%~dp0platform-tools\adb.exe" kill-server
:: kill all nox app player adb and adb ..
taskkill /F /IM adb.exe 2> %~dp0\null
taskkill /F /IM nox_adb.exe 2> %~dp0\null
I can't seem to find emulator-5562 any place ... searching my entire disk ... if I start adb no matter what I get emulator-5562 after a few seconds ... no other adb running or emulators etc no bluestacks BS or android studio .. FYI my Android Testing Suite JAMBOREE gets you up an running in under 2min
https://github.com/freeload101/Java-Android-Magisk-Burp-Objection-Root-Emulator-Easy/
taskkill /F /IM adb.exe
adb kill-server normally works but ... in my case ...
my problem is about android and the adb commands. I'm working on a Nexus 5 and i want to install and apk with adb commands. So i start with adb devices, my mobile is detected by the computer so i go to the repertory where the apk is located and i launch adb install name.apk
It returns :
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
error: device not found
- waiting for device -
The Nexus 5 is rooted, and usb debug is activated
adb devices give me some sort of serial number of the mobile
If adb devices gives you a list of devices, then you could try to take serial number of your device and call adb -s <serialNumber> install name.apk. Here is more options you could try.
If you are using Ubuntu try restarting the adb server by giving sudo permission.cd > adb location and do sudo ./adb kill-server and sudo ./adb start-server.
When I type "adb devices", it will list:
emulator-5554 device <-- this is emulator
0123456789ABCDEF device <-- this is my smartphone
A software called ShareKM will automatically detect the first device in the list thus will cause an error "Android app is not installed".
So what I did is, close the emulator, adb kill-server, adb start-server, launch ShareKM, launch emulator. If I "adb devices" it will be:
0123456789ABCDEF device <-- this is my smartphone
emulator-5554 device <-- this is emulator
But this is too hustle.
Is there a command to rearrange the list without killing or restart emulator? Lets say "adb put 0123456789ABCDEF to 1"
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.
May be adb kill-server helps for you?
or
adb -s emulator-5544 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
FOR MAC:
Run:
ps -ax | grep emulator
which gives you a wide result. Something like:
6617 ?? 9:05.54 /Users/nav/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64 -netdelay none -netspeed full -avd Nexus_One_API_29
6619 ?? 0:06.10 /Users/nav/Library/Android/sdk/emulator/emulator64-crash-service -pipe com.google.AndroidEmulator.CrashService.6617 -ppid 6617 -data-dir /tmp/android-nav/
6658 ?? 0:07.93 /Users/nav/Library/Android/sdk/emulator/lib64/qt/libexec/QtWebEngineProcess --type=renderer --disable-accelerated-video-decode --disable-gpu-memory-buffer-video-frames --disable-pepper-3d-image-chromium --enable-threaded-compositing --file-url-path-alias=/gen=/Users/nav/Library/Android/sdk/emulator/lib64/qt/libexec/gen --enable-features=AllowContentInitiatedDataUrlNavigations --disable-features=MacV2Sandbox,MojoVideoCapture,SurfaceSynchronization,UseVideoCaptureApiForDevToolsSnapshots --disable-gpu-compositing --service-pipe-token=15570406721898250245 --lang=en-US --webengine-schemes=qrc:sLV --num-raster-threads=4 --enable-main-frame-before-activation --service-request-channel-token=15570406721898250245 --renderer-client-id=2
6659 ?? 0:01.11 /Users/nav/Library/Android/sdk/emulator/lib64/qt/libexec/QtWebEngineProcess --type=renderer --disable-accelerated-video-decode --disable-gpu-memory-buffer-video-frames --disable-pepper-3d-image-chromium --enable-threaded-compositing --file-url-path-alias=/gen=/Users/nav/Library/Android/sdk/emulator/lib64/qt/libexec/gen --enable-features=AllowContentInitiatedDataUrlNavigations --disable-features=MacV2Sandbox,MojoVideoCapture,SurfaceSynchronization,UseVideoCaptureApiForDevToolsSnapshots --disable-gpu-compositing --service-pipe-token=--lang=en-US --webengine-schemes=qrc:sLV --num-raster-threads=4 --enable-main-frame-before-activation --service-request-channel-token= --renderer-client-id=3
10030 ttys000 0:00.00 grep emulator
The first (left) column is the process ID (PID) that you are looking for.
Find the PID in the first (top) row. In the above example, it's 6617.
Kill that process:
kill PID
In my case, the command is:
kill 6617
Usually, killing the first process in enough to stop the emulator, but if that doesn't work, you can:
5.1. try killing other processes as well.
5.2 kill with -9 (force kill):
kill -9 PID
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
if
adb kill-server
doesn't work. Use :
adb emu kill
this will kill all the emulators
If multiple emulators are present then use:
adb -s * emu kill
Sometimes the command
adb -s emulator-5554 emu kill
did not work on my CI servers or desktops, for unknown reason.
I think on Windows it's OK to kill the process of qemu, just like
Taskkill /IM qemu-system-x86_64.exe /F /T
I can close it with:
adb shell reboot -p
The other answer didn't work for me (on Windows 7). But this worked:
telnet localhost 5554
kill
Why not just do
adb reboot bootloader
If you don't want to have to know the serial name of your device for adb -s emulator-5554 emu kill, then you can just use adb -e emu kill to kill a single emulator. This won't kill anything if you have more than one emulator running at once, but it's useful for automation where you start and stop a single emulator for a test.
adb kill-server will kill all emulators and restart the server clean.
None of the solutions worked for me. I had to go the telnet way including authentication:
AUTH=$(cat "$HOME/.emulator_console_auth_token")
expect << EOF
spawn telnet localhost 5554
expect "OK"
send "auth $AUTH\r"
expect "OK"
send "kill\r"
expect "OK"
send "exit\r"
EOF
The full script can be obtained with a free license from https://github.com/kullo/android-emulator-tools
Update: looks like this still does not reliably close the console and ADB ports (e.g. 5554,5555)
I use this one-liner, broken into several lines for readability:
adb devices |
perl -nle 'print $1 if /emulator-(\d+).device$/' |
xargs -t -l1 -i bash -c "
( echo auth $(cat $HOME/.emulator_console_auth_token) ;
echo kill ;
yes ) |
telnet localhost {}"
To automate this, you can use any script or app that can send a string to a socket. I personally like nc (netcat) under cygwin. As I said before, I use it like this:
$ echo kill | nc -w 2 localhost 5554
(that means to send "kill" string to the port 5554 on localhost, and terminate netcat after 2 seconds.)
This scrips can help you to kill All emulators at once:
Filter emulators (because you can have a mixing on physical and emus)
Kill all emus by ADB id
Disadvantage of this solution: if your emu just "stuck" you can't kill it with adb command and it required process kill. But that's very rare case.
while [ "`adb devices | grep -Eoh \"emulator-\d{0,4}\" | wc -l | tr -d ' '`" != "0" ]; do
echo "Connected emulators:"
adb devices | grep -Eoh "emulator-\d{0,4}"
for emulator in $(adb devices | grep -Eoh "emulator-\d{0,4}")
do
echo "Killing the emulator: $emulator"
adb -s "$emulator" emu kill | true
done
sleep 10;
done
echo "All emus has been killed"
List of devices attached
emulator-5584 host
emulator-5580 host
emulator-5576 host
emulator-5572 host
emulator-5568 host
emulator-5564 host
emulator-5560 host
C:\Users\Administrator>adb -s emulator-5584 emu kill
error: could not connect to TCP port 5584: cannot connect to 127.0.0.1:5584: No connection could be made because the target machine actively refused it. (10061)
NOTE: gui of emulator is not running but still it's showing
SOLUTION:
adb kill-server
start emulator using:
emulator.exe -netdelay none -netspeed full -avd Nexus_5X_API_19
On Linux when the process became unresponsive the only way I could terminate the emulator was using the command:
kill -9 `pidof adb`
which finds the process ID of adb and sends a kill -9 signal to it.
to get your devices name try to run this on Android Studio terminal
adb devices
after you get devices name, kill app with this comment
adb -s emulator-5554 emu kill
where
emulator-5554
is your device name
On Windows 10, with Android Studio 2021.1.1 patch 3, the adb -s emulator-5554 emu kill command does not work, adb being not recognized.
But here's the solution using the Tool/Device Manager. Simply select the active emulator and click on x to stop it.