Android adb logcat 挂起并显示“正在等待设备”消息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10005509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:09:10  来源:igfitidea点击:

adb logcat hangs with "waiting for device" message

androidadbandroid-logcatcts

提问by Android Boy

When I type adb devicescommand on terminal, it shows device is connected

当我adb devices在终端上输入命令时,它显示设备已连接

List of devices attached

0123456789ABCDEF device

连接的设备列表

0123456789ABCDEF装置

But when I type adb logcatcommand, it hangs with below message

但是当我输入adb logcat命令时,它会挂起以下消息

waiting for device

等待设备

Can anybody tell me what is the problem behind this? I test the device on cts.

谁能告诉我这背后的问题是什么?我在 cts 上测试设备。

采纳答案by Deva

I am not pretty much sure if this works for you but can you please try the steps below:

我不太确定这是否适合您,但您可以尝试以下步骤:

# Kill and restart      
$ adb kill-server      
$ adb start-server     
 daemon not running. starting it now *      
 daemon started successfully *         

# Device appears, but is listed as offline

$ adb devices      
$ adb logcat

回答by Karbon62

I have also experienced similar problems I think I solved it by having the USB debugging option switched on within Developer Options in Settings.

我也遇到过类似的问题,我想我是通过在“设置”中的“开发人员选项”中打开 USB 调试选项来解决的。

REPEAT The following steps above, it should work!

重复以上步骤,应该可以了!

回答by Omkar Nisal

I got Nexus tab today and I had to go to Settings-> About Tablet-> (tap 7 or 8 times) on Build Number.

我今天得到了 Nexus 选项卡,我必须在 Build Number 上转到Settings-> About Tablet-> (点击 7 或 8 次)

Then 'Developer Options' showed up above 'About Tablet'.

然后“开发人员选项”出现在“关于平板电脑”上方。

Next in Developer Options, after enabling USB DebuggingI was able to get the logs

接下来在开发人员选项中,启用USB 调试后,我能够获取日志

For Mac Users:

对于 Mac 用户:

cd /Applications/Android/sdk/platform-tools

cd /Applications/Android/sdk/platform-tools

./adb logcat

./ adb logcat

回答by Bobby

I had this same problem on Ubuntu 12.04. Thankfully MickeyMicro had the solution that worked for me:

我在 Ubuntu 12.04 上遇到了同样的问题。幸运的是,MickeyMicro 有适合我的解决方案:

  1. Run the command: gksudo gedit /etc/udev/rules.d/51-android.rules

  2. Add the following line to the blank file

  1. 运行命令:gksudo gedit /etc/udev/rules.d/51-android.rules

  2. 将以下行添加到空白文件中

SUBSYSTEM=="usb", ATTR{idVendor}="2080", MODE="0666" (I used this one on 12.04)

SUBSYSTEM=="usb", ATTR{idVendor}="2080", MODE="0666" (我在 12.04 使用过这个)

SUBSYSTEM=="usb", SYSFS{idVendor}="2080", MODE="0666" (Another recommended for 10.04)

SUBSYSTEM=="usb", SYSFS{idVendor}="2080", MODE="0666" (10.04 推荐的另一个)

  1. Save and close gedit.

  2. Run the command: sudo chmod a+rx /etc/udev/rules.d/51-android.rules

  3. Restart the system.

  4. Run the command: sudo sh -c "mkdir -p ~/.android; echo 0x2080 > ~/.android/adb_usb.ini; adb kill-server; adb devices"

  5. Verify that you have permissions to access the device. adb devices should return normal response, rather than a "???????????? no permissions" message.
  1. 保存并关闭 gedit。

  2. 运行命令:sudo chmod a+rx /etc/udev/rules.d/51-android.rules

  3. 重新启动系统。

  4. 运行命令:sudo sh -c "mkdir -p ~/.android; echo 0x2080 > ~/.android/adb_usb.ini; adb kill-server; adb devices"

  5. 验证您是否有权访问该设备。adb 设备应返回正常响应,而不是“???????????? 无权限”消息。

http://forum.cyanogenmod.com/topic/23163-need-help-for-adb-connection-on-ubuntu/

http://forum.cyanogenmod.com/topic/23163-need-help-for-adb-connection-on-ubuntu/

回答by Kaiserludi

When I have experienced this infinite "waiting for device" on Windows I had simply forgotten to enable usb-debugging in the developer options of my device.

当我在 Windows 上经历这种无限的“等待设备”时,我只是忘记在我的设备的开发人员选项中启用 USB 调试。

回答by Geremy

Here is yet another potential method to solve this -- in the past, the above solutions will work, but in my case, this time, this was the thing that fixed it:

这是解决此问题的另一种潜在方法 - 在过去,上述解决方案会起作用,但就我而言,这一次,这是解决问题的方法:

  1. Plug device into USB
  2. Settings -> Developer Options
  3. Revoke USB Debugging Authorization
  4. Unplug Device
  5. Repeat Step 1
  6. Authorize Device
  7. Repeat Steps 4&5
  1. 将设备插入 USB
  2. 设置 -> 开发者选项
  3. 撤销USB调试授权
  4. 拔下设备
  5. 重复步骤 1
  6. 授权设备
  7. 重复步骤 4 和 5

adb devices should now show device

adb devices 现在应该显示设备

adb logcat should now output logs from device

adb logcat 现在应该从设备输出日志

回答by Chris A

What OS are you using? It can be a variety of different reasons. Did you make sure you only have either the emulator running or a device attached? If so, you can direct your adb command by using the -d or the -e flag.

你使用的是什么操作系统?这可能是各种不同的原因。您是否确定只运行了模拟器或连接了设备?如果是这样,您可以使用 -d 或 -e 标志来指导您的 adb 命令。

回答by Oak Bytes

I had similar problem on Galaxy S3, with adb running on Ubuntu 11.10 OS. In my case, If I reconnect the device (pull the USB connection and reconnect it), the log cat starts working. This happens only for the first time I connect the device after powering it up. Once logcat starts working, then it continues to work smoothly, without needing to reconnect.

我在 Galaxy S3 上遇到了类似的问题,adb 在 Ubuntu 11.10 操作系统上运行。就我而言,如果我重新连接设备(拔下 USB 连接并重新连接),日志猫就会开始工作。这只发生在我第一次接通电源后连接设备时。一旦 logcat 开始工作,它就会继续顺利工作,无需重新连接。

回答by UVRadiation

This happend to me on OS X mountain lion. To fix it I had to
open Activity Monitor, filter all processes named "adb" and force quit them (I had 3 running). Then reconnect the device and everything was working again.

这在 OS X 山狮上发生在我身上。要修复它,我必须
打开活动监视器,过滤所有名为“adb”的进程并强制退出它们(我运行了 3 个)。然后重新连接设备,一切又正常了。

回答by Luke Dupin

I had a similar problem, but for different reasons. My issue came from programing usb accessory on android, which changes the vid/pid when in accessory mode. The solution for me that worked was the following:

我遇到了类似的问题,但原因不同。我的问题来自在 android 上对 USB 配件进行编程,它在配件模式下会更改 vid/pid。对我来说有效的解决方案如下:

  1. Connect the phone
  2. Run the usb host side accessory mode commands (Example website: http://android.serverbox.ch/?p=262)
  3. Phone should have reconnected in accessory mode (Ensure the PID has adb: 0x2D01)
  4. adb kill-server
  5. sudo adb start-server (This caused the phone to re-ask auth permission)
  6. adb logcat (In my case I wanted to watch the logs, this now worked in accessory mode)
  1. 连接手机
  2. 运行 USB 主机端附件模式命令(示例网站:http: //android.serverbox.ch/?p=262
  3. 手机应该在附件模式下重新连接(确保 PID 有 adb: 0x2D01)
  4. adb 杀死服务器
  5. sudo adb start-server (这导致手机重新询问身份验证权限)
  6. adb logcat(在我的情况下,我想查看日志,现在可以在附件模式下使用)