Linux 下使用adb devcies 出现乱码


参考 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="<username>"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
# adb protocol on maguro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"
# fastboot protocol on maguro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"

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.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值