Linux 下adb 驱动问题
Linux下使用手机USB调试模式连接ADB进行Android程序的调试,配置驱动没有Windows来的直观。
具体步骤首先确认手机连接上电脑,lsusb查看下设备记录。
matthew@matthew-1230-laptop:~$ lsusb
Bus 007 Device 009: ID 18d1:4e12
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 004: ID 093a:2510 Pixart Imaging, Inc.
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
我这里是:
Bus 007 Device 009: ID 18d1:4e12
然后在/etc/udev/rules.d/下创建一个配置文件: 51-android.rules
sudo vim /etc/udev/rules.d/50-android.rules
针 对Linux ADB驱动配置文件里的SYSFS参数是指设备厂商。当初因为是HTC帮Google做的手机,所以官网一开始的用例上写的是”High Tech Computer Corp.”。但现在Moto, 索爱, 三星等一批手机厂商的加入,Android生产厂商已不只HTC一家。而且且如果设备型号不是0bb4那该怎么办呢?
读sdk帮助文档的时候,发现sdk已经提供了说明:
(详见:docs/guide/developing/device.html)
If you’re developing on Ubuntu Linux, you need to add a rules file that contains a USB configuration for each type of device you want to use for development. Each device manufacturer uses a different vendor ID. The example rules files below show how to add an entry for a single vendor ID (the HTC vendor ID). In order to support more devices, you will need additional lines of the same format that provide a different value for the SYSFS{idVendor} property. For other IDs, see the table of USB Vendor IDs, below.
1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
For Gusty/Hardy, edit the file to read: [注:ubuntu 7.10及以后版本]
SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Dapper, edit the file to read: [注:ubuntu 6.06及以前版本]
SUBSYSTEM==”usb_device”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
2. Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules
只要按照说明把创建的51-android.rules文件中的0bb4修改为相应的USB供应商ID信息即可。
比如我的手机是motorola,idVender是22b8
那么这一行就是
SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"
但是这上面的ID,并不能包括所有,我手上就有一台设备的USB ID就不在上述之列。
解决办法是你可以使用lsusb命令查看你的USB ID
matthew@matthew-1230-laptop:~$ lsusb
Bus 002 Device 003: ID 413c:2003 Dell Computer Corp. Keyboard
Bus 002 Device 002: ID 0461:4d22 Primax Electronics, Ltd
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 010: ID 18a1:0002
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub