ubuntu adb 无法识别手机


在linux下android开发,我经常遇到usb调试时,手机无法识别

$ adb devices  
List of devices attached   
????????????    no permissions  

本质上是adb server启动需要权限造成的,可以用以下的方法来解决问题。
解决方法:

1)断开手机连接先执行

$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 006: ID 0cf3:3004 Atheros Communications, Inc. 
Bus 003 Device 003: ID 040b:2013 Weltrend Semiconductor 
Bus 003 Device 002: ID 174f:1474 Syntek 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub 


连接手机,再执行一次lsusb 

Bus 002 Device 002: ID 8087:8000 Intel Corp.   
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
Bus 001 Device 002: ID 8087:8008 Intel Corp.   
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub  
Bus 003 Device 006: ID 0cf3:3004 Atheros Communications, Inc.   
Bus 003 Device 009: ID 18d1:9025 Google Inc.   
Bus 003 Device 003: ID 040b:2013 Weltrend Semiconductor   
Bus 003 Device 002: ID 174f:1474 Syntek   
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
 


那多出来的Bus 003 Device 009: ID 18d1:9025 Google Inc. 就是你的手机。
使用 vim 新建一个配置文件

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

内容填写如下

SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="9025",MODE="0666" 


##修改18d1和9025,把他改成你的设备## 
运行以下命令:
sudo chmod a+rx /etc/udev/rules.d/70-android.rules  
sudo /etc/init.d/udev restart  


在 Android sdk 的 tools 目录下运行 (这一步很重要,必须要sudo,否则没效果)

sudo adb kill-server 
sudo adb start-server 
sudo adb devices


修改完成后,将手机USB线与电脑断开,再连就会显示

$ sudo adb devices  
List of devices attached   
1234567890ABCDEF    device  


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值