Why does adb have a high CPU usage? - android

I'm using my T61 laptop to develop Android applications. Starting the debug bridge's server with adb start-server does create a process which runs at 100% CPU, see the output of ps:
stephan 19837 99.3 0.0 19952 908 pts/0 Sl 13:50 3:42 adb fork-server server
This is annoying especially since eclipse with the ADT plugin automatically starts this server (and the same problem occurs). I'm running Ubuntu Natty, but the same occurred also under Maverick and Debian sid. I'm sure that this problem did not occur after Ubuntu was freshly installed on the laptop, but started after a few days. What I noticed is also that adb fails to recognize devices that are connected to the computer while adb is running. If I restart the server with the not recognized device it is recognized after the restart. Maybe this is related?
As I said, it is installed on a T61 Laptop, using Ubuntu 11.04 Natty 64bit and 32bit with kernel 2.6.38-8-generic, but it also occurred on Ubuntu 10.10 32bit with the most recent PAE kernel, and on Linux Mint 10 64bit with the same(?) kernel version, and on aptosid 64bit with also some 2.6.38 kernel. Devices I use for testing are the G1, the Nexus (1) and a Samsung Spica. It is independent on which device is connected. My udev rules have been modified such that these devices are chmoded correctly. I have also a desktop machine with Ubuntu 10.10 64bit running, where this does not occur.
In this bug report it was claimed (a) that a kernel version change did solve this issue, that didn't work for me, and (b) a procedure requiring root access to the device. I'd like to solve this without rooting my phone, especially since this appears with multiple different phone models connected to the computer.
Edit: Please note that I don't have that laptop anymore and I couldn't solve the problem until I got rid of it. On my new computer the problem does not occur. Therefore I cannot check any solutions upon their validity and, thus, cannot mark a solution as accepted. (Should I close this question? Or what is the preferred way on StackOverflow to handle such a situation?)

Same problem on iMac 9,1 Ubuntu 10.10.
adb fork-server server keep one core of the cpu to 90-100%
No power/suspend/resume possible issue in my case.
I just started eclipse after a boot.
"Solved" with these steps:
Power off, start eclipse, plug-in device (or start emulator)

I was still facing this issue and I figured it out the it was the firefox extension that caused the issue. Get the pid of adb process by
$ps aux | grep adb
Then get the actual executable details by
$ls -l /proc/$PID/exe
You will get the adb process details. In my case the output was.
prabhat#paradise ~ $ ls -l /proc/16695/exe
lrwxrwxrwx 1 prabhat prabhat 0 Jan 24 21:02 /proc/16695/exe -> /home/prabhat/.mozilla/firefox/c05prhhc.dev-edition-default/extensions/adbhelper#mozilla.org/linux64/adb
I simply deleted the extensions folder as I am not using it currently...

I have the same problem and work around it by rebooting until ADB works correctly.
I've noticed the following may make a difference:
Plug-in your phone before starting eclipse (which in turn starts ADB).
Power down your computer and leave it off for a minute rather than just rebooting.
For me, the problem often occurs if my computer fails to return from suspend. However, this is probably just because I never reboot my laptop (apple MBP) unless that happens. I just suspend and resume. I've found that suspend/resume is fine. This does not affect ADB.
I was also the one that posted the comment in that bug report about rolling back the kernel version. However, I posted another comment further down indicating that that made no difference. I must've just been lucky that time.
One other interesting point. I also have a desktop machine that never has this ADB problem. However, I am conservative with my updates on that machine, as I don't want this problem to occur there.
I would speculate that this could be a ACPI or power saving related bug in ubuntu/debian. I never suspend my desktop machine.

Related

Android emulator freeze my whole system when it can't connect to adb daemon

I recently changed my computer and took the opportunity to move from Mageia to Fedora. But I can't do any Android development anymore because, as stated in the title, starting any AVD makes the whole system to freeze (screen, mouse and keybord) if the AVD can't connect to adb daemon. The only thing I can do is hard shutdown.
The problem here is adb daemon is always started when I try to launch an AVD as the service is enabled by default, so that shouldn't happen.
What I've been able to collect so far is a few logs in a file by lauching the emulator from command-line. All it says before freezing is:
emulator: INFO: GrpcServices.cpp:301: Started GRPC server at 127.0.0.1:8554, security: Local
emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
But, if I manually restart the adb service just before lauching the AVD, I don't experience the freeze. Instead, I get the following errors before the AVD crashes:
cannot add library .../android-sdk-linux/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
added library .../android-sdk-linux/emulator/lib64/vulkan/libvulkan.so
cannot add library .../android-sdk-linux/emulator/lib64/vulkan/libvulkan.so.1: full
My best guess here is there's something bad going on with the graphic card. Something I am seemingly the only one to exprerience as I couldn't find any relevant result on internet. I must mention here that I've already tried to run several AVDs in multiple API versions, both software and hardware rendered graphics and I always get the same result.
My system configuration is
AMD Ryzen 9
Nvidia GeForce RTX 2070 using the Nouveau drivers
kernel 5.11.
If anyone ever stumbles upon this question facing the same issue than me, that was solved by getting rid of the Nouveau drivers and using Nvidia's proprietary drivers. A handful of other disturbing bugs on my computer were solved by doing just that.
I really don't understand why some Linux distribution still strongly advise to use the Nouveau drivers over Nvidia'as when they have a such a really poor support of the GPUs...

"adb pull" stuck in half way

Suddenly my "adb pull" command will stuck in the middle of the process.
I'm not sure what cause it, after install some application or driver.
Happens for Pull one files or multiple files.
Does anyone encounter the same issue before? thanks.
Example:
U:\batch>adb pull /sdcard/xxxlog/mobilelog .\xxxlog\
[ 94%] /sdcard/xxxlog/mobilelog/APLog_xxx/main_log_1__xxx: 87%
Here a screenshot from my console
for my specific answer, and provide a possible answer to who encounter similar problem.
after I reinstall the whole os, testing different adb version,
the issue still remains.
during testing adb version,
I found the issue will not happens if i use Local Disk...
where issue happens when using Network Drive..
So a possible solution, is don't use Network drive
I encountered similar problem on adb server (v 1.0.40) started on Windows 7 machine. When tried to pull files from device on other machine running Linux in same local network (I used: "adb -H pull ...") the adb was freezing occasionally.
The solution was to not use Windows for ADB server.
This problem was NOT visible, when adb server was running on Linux VM (Ubuntu 16.4/ VirtualBox). Hope that this helps.
BR,
Ziggy
Every time I encounter this, it ends up being a max path length issue. Open a shell on the device using adb and review the file names within the directories that you are pulling. If any have exceedingly long names, they will silently fail and adb will hang
The thing that really throws you for a loop is that it usually fails after giving a percentage complete which makes you think it's a faulty connection or some other issue.
I haven't found a good way to recursively list out file names in shell and test their name length prior to doing the pull in order to know that the issue is going to happen, but when I have the same issue and rename long files, it ends up working on the next attempt.
I encountered the same problem when trying to transfer a large amount of data from an Android phone to a Raspberry Pi 3B+, and the logcat output seemed to reveal that adb was silently failing due to an issue with USB buffer reads (unfortunately, I don't have the exact message with me).
After the initial failure, it was possible to get another few files individually by unplugging the phone, running adb kill-server and adb start-server, and plugging it back in between each one, but the only longer-term fix I could find was restarting the Raspberry Pi. This solution, however, is not permanent, and must be repeated occasionally.
I was not able to replicate this issue on Windows or on a traditional Ubuntu system.
I encountered this problem while copying files from My Ubuntu machine to my Pixel 7.
A workaround based on this bug report, is to run
adb shell exit
in another terminal whenever it gets stuck until all files are copied. You can also run
watch -n 30 adb shell exit
to run the command every 30 seconds so you don't have to keep watching the process. I hope this helps someone.

ADB commandline Hanging during install (PhoneGap)

My Phonegap app refuses to load onto my Android device (even the HellowWorld default app is refusing to load)
Everything was running just great until today.
Here's my console log:
***\>adb devices
List of devices attached
4c05609b device
***\>phonegap run --device -V android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Compiling app on platform "android" via command "cmd" /c ***\platforms\android\cordova\build
[phonegap] Platform "android" compiled successfully.
[phonegap] successfully compiled Android app
[phonegap] installing app onto device
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Running app on platform "android" via command "cmd" /c ***\platforms\android\cordova\run --device
It just sits there saying running... forever.
I have another terminal window open with adb logcat running and at some point (maybe 10-15 seconds into that last line getting printed) it stops logging. Termination of the process and subsequent calls to adb logcat result in more hanging (no logging at all)
So then I have to do a kill-server, start-server to break out of this endless hanging at which point the phonegap process terminates with:
[error] An error occurred while running the android project.
***\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
ERROR: Failed to launch application on device: ERROR: Failed to install apk to d
evice: Error executing "adb -s 4c05609b install -r "***\platforms\android\bin\Po
ached-debug-unaligned.apk"": protocol failure
I have tried::
deleting my .cordova folder in C:\Users\Name
running the adb install directly (without phonegap)
deploying to an emulator (same problem)
unplugging / replugging the device
rebooting all devices
toggling "developer mode" on the device and revoking USB debugging privileges
I am all out of ideas!
Would greatly appreciate any tips or leads.
ADB version 1.0.31
Galaxy S3 running Android v4.3
EDIT:
Deploying to an emulator claims to complete successfully, but the app never opens and does not appear in the app list inside the emulator. So I have no way of actually testing it on the emulator either.
Would really appreciate some assistance.
EDIT 2:
After some further tinkering I've discovered my issue can be more specifically described as ADB hangs (freezes) when I attempt to talk to my device. I've determined this because adb shell, adb install, and adb push all fail the same way as described above. No error, just finite waiting.
adb logcat, adb devices, and other read functions work perfectly fine until one of the aforementioned write functions hangs in which case I need to do a adb kill-server or TASKKILL to get adb logcat working again.
Not sure if this added information helps, but there you go. The last thing I haven't yet tried is to do a factory reset on my phone as suggested by this fellow. If I can't find a solution soon I will back up my data as best I can and attempt this...
Please save me before this becomes my last option!
In case this helps others I had a problem with similar symptoms. ADB install -r "apk path" would hang indefinitely.
I troubleshooted a myriad of things and identified that it was my USB cable length.
I have an USB extender cable as that I plug my devices into. The combined length of my device's cable and the USB extender cable caused this issue. Removing the extension cable fix the issue and eventually I replaced my USB extender cable with a shorter extension cable for the final solution.
The issues seems to resolve itself randomly. As others suggested, an arbitrary combination of ADB kill-server, restarting the device, and re-installing SDKs seems to alleviate the problem (even if only for a couple pushes).
I still have no idea what causes this hanging and, though superstitiously believe the arbitrary combination described above fixes it, am unsure how to permanently resolve it.
To future people reading this, until a solid explanation is given my only advice is to square away an hour or so to restart / rebuild your dev environment... and make sure you buy a durable stress ball.
Shot in the dark here, but some more things to try:
Are you on a work PC or something? Make sure you have USB write permissions. Also, try different USB ports and cables. You have the latest USB driver for your devices right?
Try updating the SDK tools. Or maybe something got corrupted and a re-install might do the trick.
You have free space on your devices right?
Unknown sources is checked on both devices?
What version of Android are you targeting?
Do try restart the device like other suggested. From my experience, kill the adb process, then run the cordova run command helps magically sometimes.
In my case adb seemed to hang, but in fact the data transfer from Mac to emulator was really slow:
$ adb push platforms/android/build/outputs/apk/android-debug.apk /data/local/tmp/
150 KB/s (15587200 bytes in 101.223s)
It's a lot faster on USB connected real device. Don't know why...
Had the same (original) issue (with cordova / testing on an old device) ie. hang during install.
Tried running adb install directly from cmd line ...
adb [-s <deviceID>] install <apk>
...and same issue so not cordova specific....
Opened android device monitor (ADM) ...
..sdk\tools>monitor
..and ran install from cmd line again and saw logcat message saying package was sdk 16 / device was 15...doh!
So went back to AndroidManifest.xml and changed android:minSdkVersion to 15 and all back to normal again - install worked fine.
( Issue arose because I had installed something else which had changed the minSdkVersion and then removed the something else and never reset the minSdkVersion )
So, possibly device sdk / android version is too low for your build. If not, a look at the ADM logcat output as you initiate the install from the command line might indicate what the issue is.
Unplugging and plugging device again usually helps.

Android adb stop working

Until yesterday everything was working perfect until today that I connected my phone (just updated to Jelly Bean) and adb.exe stop working. If I execute adb.exe I can see the help but when I want to use any command it just run forever and no message is shown.
I tried with "kill-server" and "devices" and it runs forever, no message at all is displayed and I must terminate the process to close it.
I just connect the same phone to other PC that was fully functional and also adb.exe stop working. The strange thing is that adb.exe will not work any more even If I disconnect the phone and/or I connect my tablet. Adb.exe just got useless.
I was using the same phone yesterday (android 4.0), with my tablet (android 4.2) and adb.exe was working.
Adb.exe is not corrupted as I checked it MD5 and it is the same as in working pc (5787e5df1a68e7afea82d58e5f0d6549 *adb.exe).
I have Android Debug Bridge version 1.0.31 and Android SDK tools 22. I uninstalled android sdk tools and Installed again but when is near to finish it hangs because it launches adb.exe and again it will run forever.
Please any suggestion or help?
Try rebooting. Sometimes the USB drivers lock up. I work HEAVILY with ADB in my project at http://android-casual.googlecode.com and I find it to be one of three things when ADB locks up.. 1. USB drivers, or 2. adb_usb.ini needs an update, or 3. on new devices you have to "pair" them so that ADB can perform any action.
To pair, you can disconnect, reconnect and run "adb devies" to display the pairing on the device.
Not sure if you're still facing this issue, but for what it's worth I had the same kind of issue with adb.exe, and came across this post while trying to troubleshoot it. In my case, I wasn't using any physical Android devices, only the Emulator. Everything had been working fine and then suddenly adb.exe would no longer respond (couldn't get any output from any adb command - it just appeared to hang).
In the end, my issue turned out to be another application I had installed on my development machine. It was starting as a service, and was listening on the exact same port that the adb server runs on (5037), which appeared to be confusing it. Once I changed the application to use a different port, adb started working again and everything was fine.
Run command
where adb
I had such kind of situation.
In my case
where adb
gave output
C:\Windows\adb.exe
D:\AndroidSDK\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe
I tried to run adb from disk C, when Eclipse used second adb from AndroidSDK (from disk D).
I removed adb from strange path C:\Windows\adb.exe, and this solved this problem.
I got the same problem,my solution is going to cmd and paste adb.exe path,and then click enter button.For example
D:\Android\Android\platform-tools\adb.exe

Android adb (OSX Lion) does not recognize Galaxy Nexus, Jelly Bean

I've been developing my first android apps on Eclipse installed on OSX Lion. I would like to use my Jelly Beans Galaxy Nexus for debugging, but the Android Device Bridge (adb) can't find the device:
./adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
The phone is in debugging mode.
The phone is recognizable as a camera (PTP), but not as a media device (MTP). ADB does not work regardless of PTP\MTP setting.
I have restarted noth the phone and the mac
Following this advice, I've installed Android File Transfer. The ATF recognizes the device, but no luck with the ADB.
Any ideas?
Addendum: I have reported a bug for this. Workarounds are still most welcome!
Sep 5 13:28 UTC - Workaround #1: Dropbox: I've moved the OSX Eclipse workspace to Dropbox and installed Dropbox on the device. The APK is written to bin/, and I re-install it from the Dropbox app after each successful build.
I'm answering this because my boss just had the exact same issue with his Galaxy Nexus, and we finally fixed it yesterday. He had an application, "EasyTether" that was snagging his connection to ADB and it couldn't be used anywhere else. Is it possible that you've setup this application, or a similar one that might be using ADB for you? If "Android File Transfer" works (it was working in parallel with EasyTether for my boss), then your connection is active, so as long as "USB Debugging" is enabled in your settings, you should be seeing a connection. Here's a quick how-to in the event that you do have "easytether"
BEFORE you plug your phone in run the following in terminal
sudo kextunload /System/Library/Extensions/EasyTetherUSBEthernet.kext
If that fixes the issue, and you want to remove easytether altogether, you can us the rm command with the -rf flags to keep it from happening again...
sudo kextunload /System/Library/Extensions/EasyTetherUSBEthernet.kext
sudo rm -rf /System/Library/Extensions/EasyTetherUSBEthernet.kext
You can use adb over wifi.
See this post to do it yourself.
or there are quite a lot of apps on google play. But these need root access
Try taking the usb stick out of the phone and put it back
Try taking it out of the mac and put it back
Try to put the stick in another port
Try to wriggle the stick so you are sure it is connected.
There is a long discussion with possible solutions here: Can't find android device using "adb devices" command
Have you tried a different cable? I ordered a bunch of cheap cables off of eBay, and the first one I used would not work for adb. It did work for charging and file transfers however.

Categories

Resources