参考 http://www.ourunix.org/post/151.html


以前在模拟器上跑程序,这一次小组好不容易整了个G3,为了证明自己的Android没有白浪费时间自学,写了个“hello,walfred”,编译生成apk,可是通过usb连接上电脑却出现问题。

使用adb devices 出现如下:

List of devices attached

???????????? no permissions

同时在DDMS中显示设备名也显示????????????,也无法显示进程名,无法查看log。

解决方法:

1、设置usb权限

因为ubuntu这样的系统都是默认以非root身份在运行的,要使用usb调试,需要sudo支持。

$ lsusb

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 003: ID 413c:2106 Dell Computer Corp.

Bus 002 Device 002: ID 0461:4d81 Primax Electronics, Ltd

Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 001 Device 010: ID 0bb4:0c87 High Tech Computer Corp.

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

列表中,Bus 001 Device 010: ID 0bb4:0c87 High Tech Computer Corp. 这一行为htc手机的usb使用端口,记录一下,id为0bb4(基于上所有的htc都是这个ID)据网上的资料说,由于后来的使用Android系统的手机越来越多,每款手机都分配了idVendor,但解决方法都一样。

$sudo vim /etc/udev/rules.d/70-android.rules

加入以下内容:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0c87",MODE="0666"

其中的idvendor idProduct指的是USB的ID可以使用lsusb查询得到。

比如我的是:在你没有连接其他外设之前只要找到最后不是root hub的这一行留意下就行。

Bus 001 Device 010: ID 0bb4:0c87 High Tech Computer Corp

ID 0bb4 就是idVendor ,0c87就是 idProduct

运行命令,重启udev:

$sudo chmod a+rx /etc/udev/rules.d/70-android.rules

$sudo service udev restart

2、不需要重启计算机,重新启动adb server下就ok

(很重要)拔掉usb重新连上再执行:

sudo ./adb kill-server

./adb devices

./adb root (这一步很重要 )


官网做法:

 http://source.android.com/source/initializing.html

Configuring USB Access

Under GNU/linux systems (and specifically under Ubuntu systems),regular users can't directly access USB devices by default. Thesystem needs to be configured to allow such access.

The recommended approach is to create a file/etc/udev/rules.d/51-android.rules (as the root user) and to copythe following lines in it. must be replaced by theactual username of the user who is authorized to access the phonesover USB.

# adb protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER=""# fastboot protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER=""# adb protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER=""# fastboot protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER=""# adb protocol on maguro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER=""# fastboot protocol on maguro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER=""

Those new rules take effect the next time a device is plugged in.It might therefore be necessary to unplug the device and plug itback into the computer.

This is known to work on both Ubuntu Hardy Heron (8.04.x LTS) andLucid Lynx (10.04.x LTS). Other versions of Ubuntu or othervariants of GNU/linux might require different configurations.



更多相关文章

  1. Android(安卓)GridView 滑动条设置一直显示状态(推荐)
  2. 【Android(安卓)Developers Training】 96. 运行一个同步适配器
  3. ANDROID编程技巧
  4. iTextPdf最简单最彻底解决中文显示
  5. Android(安卓)获取手机联系人列表
  6. 详解Android(安卓)视频播放时停止后台运行的方法
  7. Android(安卓)TextView中文字设置超链接、颜色、字体 大杂烩
  8. adb命令总结
  9. Android简明开发教程十七:Dialog 显示图像

随机推荐

  1. (三)Android数据结构学习之队列
  2. Pyqt adb 获取Android手机屏幕
  3. 别人花了几万元学的Android高级技术,我帮
  4. android可执行文件交叉编译和运行
  5. Android中如何解析网页,获取网页中的元素
  6. Android(安卓)进阶14:源码解读 Android(安
  7. Android获取屏幕大小和设置无标题栏
  8. Android开发人员需要具备的知识(很全)!
  9. Android开发者必知的5个开源库
  10. Android群英传学习——第六章、Android绘