天天看点

Linux下Android ADB驱动安装详解

linux下android adb驱动安装详解

最近由于内置的合作商比较多,本人使用的ubuntu系统好多厂商的android手机都无法正确的识别,经过一番折腾,和查阅sdk,现把linux下adb驱动配置的方法和当中会遇到的相关问题的解决方法整理出来贡献给大家。

linux下使用手机usb调试模式连接adb进行android程序的调试,配置驱动没有windows来的直观。

首先确认手机连接上电脑,lsusb查看下设备记录。

我这里是:

然后在/etc/udev/rules.d/下创建一个配置文件: 51-android.rules

文件里添加如下配置参数:

保存,给配置文件设置下权限

restart

最后再重启下adb服务,就可以了(没配置环境变量的请进入android sdk tools目录执行sudo ./adb kill-server ./adb devices)

sysfs参数:

针对linux adb驱动配置文件里的sysfs参数是指设备厂商。当初因为是htc帮google做的手机,所以官网一开始的用例上写的是”high tech computer corp.”。但现在moto, 索爱, 三星等一批手机厂商的加入,android生产厂商已不只htc一家。而且且如果设备型号不是0bb4那该怎么办呢?</blockquote>

读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

那么这一行就是

不过,你可以写多行,以使用各种设备。比如我就写了所有的,如下:

但是这上面的id,并不能包括所有,我手上就有一台设备的usb id就不在上述之列。

解决办法是你可以使用lsusb命令查看你的usb id

找到上面的id为18a1,在文件中添加设备就可以了。

修改/etc/udev/rules.d/51-android.rules不需要重启linux机器,重新插拔一下设备就可以了。再次运行adb devices就可以看到你的设备已经连接

而在此之前,你可能看到的是

http://androidappdocs.appspot.com/guide/developing/device.html

http://androidappdocs.appspot.com/guide/developing/device.html#vendorids

继续阅读