红联Linux门户
Linux帮助

android手机连接到ubuntu中进行USB调试

发布时间:2016-03-13 10:34:48来源:linux网站作者:cwll2009

1.usb连接手机(手机需要切换到usb调试模式 设置-->应用程序-->开发-->usb调试),
ubuntu@ubuntu-Lenovo-Product:~$ lsusb
Bus 002 Device 003: ID 17ef:600e Lenovo
Bus 002 Device 010: ID 12d1:1073 Huawei Technologies Co., Ltd.
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 0cf3:9271 Atheros Communications, Inc. AR9271 802.11n
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
下面一行是连接的设备:
Bus 002 Device 010: ID 12d1:1073 Huawei Technologies Co., Ltd.


2、配置udev规则文件,调整设备文件权限
接下来我们就可以根据前面获得的usb调试设备标识来调整我们的设备文件的各种属性以帮助android sdk识别usb调试设备。
在/etc/udev/rules.d下创建规则文件50-android.rules
# mk file with a new window
sudo gedit 50-android.rules

# add something as:
USBSYSTEM="usb",ATTRS{idVendor}=="12d1",ATTRS{idPorduct}=="1073",MODE="0666"

# save & close window
重启usbdev服务:
ubuntu@ubuntu-Lenovo-Product:~$sudo /etc/init.d/udev restart


3.重启adb服务
ubuntu@ubuntu-Lenovo-Product:~$adb kill-server
ubuntu@ubuntu-Lenovo-Product:~$sudo adb start-server
非常重要!上面一行一定要用sudo 运行,不然adb devices时会出现如下错误:
ubuntu@ubuntu-Lenovo-Product:~$ adb devices
List of devices attached
???????????? no permissions
查看连接设备:
ubuntu@ubuntu-Lenovo-Product:~$ adb devices
List of devices attached
XGCDU15C08011576 device

 

本文永久更新地址:http://www.linuxdiyf.com/linux/18889.html