简体   繁体   English

连接到模拟USB附件时Logcat不起作用

[英]Logcat doesn't work when connected to a simulated usb accessory

The app I am developing connects to a USB accessory which I simulate in the same pc I use to program/debug. 我正在开发的应用程序连接到USB配件,该配件可以在用于编程/调试的同一台PC中模拟。
The problem is, whenever the Tablet changes to accessory mode I am unable to connect to the Logcat through USB.(The tablet name in adb changes to a number-Id) 问题是,每当平板电脑更改为附件模式时,我都无法通过USB连接到Logcat。(adb中的平板电脑名称更改为数字ID)
I can connect to it via WiFi but whenever I reconnect the tablet (eg to reset the usb accessory mode) the adb connection resets back to usb. 我可以通过WiFi连接到它,但是每当我重新连接平板电脑(例如,重置USB附件模式)时,adb连接都会重置回usb。
I know it is possible to have the Logcat running on USB while in accessory mode. 我知道可以在配件模式下使Logcat在USB上运行。 I just can't find out why this doesn't work for me. 我只是不知道为什么这对我不起作用。

I have followed the install steps for the adt-bundle; 我已经按照adt-bundle的安装步骤进行了操作; tried reinstalling; 尝试重新安装; tried with Android Studio. 在Android Studio上尝试过。

Any ideas? 有任何想法吗?

I found the solution for my problem. 我找到了解决我问题的方法。 By restarting the adb server using sudo I was able to get Logcat messages from the device while it is connected to my simulated usb accessory. 通过使用sudo重新启动adb服务器,当设备连接到模拟的USB附件时,我能够从该设备获取Logcat消息。

sudo ./adb kill-server
sudo ./adb start-server
sudo ./adb devices

Thanks to Leon's answer here . 感谢Leon 在这里的回答。

If you don't feel like using sudo, I've found that the following solution works: 如果您不想使用sudo,我发现以下解决方案有效:

Create a file named /tmp/android.rules with the following contents (hex vendor numbers were taken from the vendor list page ): 创建一个名为/tmp/android.rules的文件,其中包含以下内容(十六进制的供应商编号来自供应商列表页面 ):

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"

Run the following commands: 运行以下命令:

sudo cp /tmp/android.rules /etc/udev/rules.d/51-android.rules
sudo chmod 644   /etc/udev/rules.d/51-android.rules
sudo chown root. /etc/udev/rules.d/51-android.rules
sudo service udev restart
sudo killall adb

Disconnect the USB cable between the device and the computer. 断开设备和计算机之间的USB电缆。

Reconnect the phone. 重新连接手机。

Run adb devices to confirm that now it has permission to access the phone. 运行adb设备以确认现在它具有访问电话的权限。

Taken from here . 取自这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM