日期:2014-05-16  浏览次数:20590 次

Ubuntu下adb看不到设备的解决方法

这个问题纠结了我2天,本来过去在ubuntu 9下连接HTC G1没有问题,按照原来的办法结果总是连接不了。

现在我的环境是Ubuntu 12 LTS 测试设备是我的Atrix 4g 死活连不上。每次kil-server以后再用adb devices后都会卡死在那, 拔掉手机后提示protocal error.沮丧!!

在baidu,google无果以后,又回到android官方查看帮助,没想到发现了一些变化。尝试下以后连接成功。看来是官方做过修改,我在stackoverflow上也看到一个印度仔和我一样的问题,不知掉他解决了没有。^_^

说下我的解决办法,其实就是官方手法的现身说教版。

首先连接手机到usb,这是一切的前提。忘记插usb的回去复习it狂人第一第二季100遍。。。 看看roy怎么说的

接下来我要找到我的设备,利用命令 lsusb 里面显示了很多条内容,选出手机那项。一般很好认,但首先你要知道自己的手机品牌。。。 不废话了

写道
Bus 002 Device 006: ID 22b8:7090 Motorola PCS

?这就是我要的了。留在后面备用。这时候打开官方指南


http://developer.android.com/guide/developing/device.html


这里是关键


写道
If you're developing on Ubuntu Linux, you need to add a udev rules file that contains a USB configuration for each type of device you want to use for development. In the rules file, each device manufacturer is identified by a unique vendor ID, as specified by the ATTR{idVendor} property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device detection on Ubuntu Linux:

Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

Use this format to add each vendor to the file:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node.

Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.
Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules

?首先文件名发生了变化,再不是50-android了 是51.具体什么原因我也不知到。。。 ubuntu下我也是新手。。。


其次文件内容也发生了改变SYSFS改为了ATTR 多了一个GROUP标签。好吧,照着改。最关键的文件内容部分

每个品牌的设备有区别的地方在于 ATTR{idVendor}=="0bb4" 这个部分 。好在我们前面就准备好了。

这里idVendor类似于品牌的名称 例如High Tech Corporation是HTC的idVendor,而我使用是moto,所以前面也看到了,我的idVendor是ATTR{“Motorola PCS”} 这里要注意加上引号。而后面 == 也需要注意 这也是刚才lsusb命令中的一部分。具体也可以看看官方帮助,已经把每个公司的USB Vendor ID列出来了,不过没看到也不要紧。可以回到lsusb命令中ID部分紧跟的就是USB Vendor ID

所以我这里改为

SUBSYSTEM=="usb", ATTR{“Motorola PCS”} =="22b8", MODE="0666", GROUP="plugdev"

这时候基本就完成了,接下来改权限

chmod a+r /etc/udev/rules.d/51-android.rules

不许要restart udev,直接跑adb devices。设备出现了。问题解决。^_^