Android adb hangs in list devices and other commands

断了今生、忘了曾经 提交于 2020-02-28 16:01:29

问题


When I try to run adb commands from terminal, especially adb devices, adb kill-server and adb start-server it hangs and I need to type CTRL+C to exit proccess. Its not possible to deploy APK to physical or virtual devices. Something is block adb proccess/port. I have anti-virus uninstalled and firewall disabled.

In the example below, I type adb devices and terminal show me List of devices attached and hangs in there.


回答1:


adb binds to TCP port 5037, if this port is in use by different process you might see that any adb commands would just hang and wont do anything.

  • Use "netstat -aon | more" commands to figure out which process is on port 5037
  • kill the process that is on 5037 and your adb commands should start working



回答2:


Something similar happened to me, I didn't have Android drivers correctly installed. You need to install Google USB Driver and then:

  1. Go to Control Panel Home

  2. Click on the "Device Manager" link.

  3. In the Device Manager locate your Android device (other devices). Then right-click on it and select "Update Driver Software".
  4. Select "Browse my computer for driver software".
  5. Select "Let me pick from a list of device drivers on my computer".
  6. Select "Show All Devices".
  7. Press the "Have Disk" button.
  8. Enter the path to the Google USB driver. Normally it is located in the following directory: C:\Program Files (x86)\Android\android-sdk\extras\google\usb_driver
  9. Select "Android ADB Interface" from the list of device types.
  10. Confirm the installation of the driver by pressing "Yes". And install it.

Complete tutorial here: http://visualgdb.com/KB/usbdebug-manual/ Hope it works!




回答3:


Try to:

Step1: Open android studio.
Step2: Choose Android device monitor.
Step3: At the device window: choose triangle icon then choose reset adb. (Try to repeat 2-3 times if it is not show some devices)



回答4:


Apart from checking for updated USB drivers...

In Windows, I've experienced hangs when using a USB hub with a harddrive, and/or other input devices attached. With my particular hardware setup, either my USB hardware is crappy, (maybe my latest USB hub is crappy) or the USB drivers for the USB controller are crappy, or I'm just running into what may be some more-or-less natural limitations to USB on the Windows platform (in regards to android hardware on Windows anyway).

EDIT: I'm particularly referencing USB3 here. I also happen to have a USB3 non-powered hub plugged into a USB2 port -- that port connects my mouse, an HDD, and my android device -- I've since had to re-think what is plugged where to ensure adb works properly.

One last helpful Windows tip, if you haven't restarted in days or weeks, might be a good idea to just restart and start fresh, and of course, Windows Updates (usually not a hindrance to how my android hardware works). Doing this can take care of another application using port 5037 (as mentioned by @par above).

I also experience issues when I try to batch several "adb pull" commands in sequence. I have been working on a setup to selectively pull a list of folders that aren't nested and thus can't be pulled in only one command that I know of (part of my custom backup solution). I sometimes find I have to pull one folder at a time. This is more likely related to my USB issues, and not so much and adb issue.

EDIT: Depending on what version of Win10 you use, you might have to manually initiate the update-check for your drivers, through the Device Manager. I actually managed to get an Android driver update by doing this recently. So far that update, and rethinking what is plugged where, things are working slightly better lately.




回答5:


just like @par said and to kill the processes, just look at their PID number and to kill them you use "taskkill /PID (their pid) /f" and put the PID number there, /f is for force kill



来源:https://stackoverflow.com/questions/38766419/android-adb-hangs-in-list-devices-and-other-commands

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!