解决方法:
1、lsusb找到设备ID
手机未连接电脑时,输入命令 lsusb,
得到:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 002: ID 062a:4101 Creative Labs
Bus 002 Device 003: ID 064e:e330 Suyin Corp.
Bus 002 Device 005: ID 04ca:3006 Lite-On Technology Corp.
手机连接电脑后,输入命令 lsusb,
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 002: ID 062a:4101 Creative Labs
Bus 002 Device 003: ID 064e:e330 Suyin Corp.
Bus 002 Device 005: ID 04ca:3006 Lite-On Technology Corp.
Bus 002 Device 007: ID 18d1:9025 Google Inc.
则新增的 Bus 002 Device 007: ID 18d1:9025 Google Inc. 即为我的手机
2、注册到udev的rules文件:
- vim /etc/udev/rules.d/51-android.rules
- 添加这个ID:1ebf,如下:
- SUBSYSTEM=="usb", ATTR{idVendor}=="1ebf", MODE="0666"
- 保存文件并运行:
- sudo chmod a+rx /etc/udev/rules.d/51-android.rules
- sudo /etc/init.d/udev restart
- 运行结果如下:
- Rather than invoking init scripts through /etc/init.d, use the service(8)
- utility, e.g. service udev restart
- Since the script you are attempting to invoke has been converted to an
- Upstart job, you may also use the stop(8) and then start(8) utilities,
- e.g. stop udev ; start udev. The restart(8) utility is also available.
- udev stop/waiting
- udev start/running, process 14636
如果想添加的更详细,也可以这样:SUBSYSTEM=="usb", ATTRS{idVendor}=="1ebf", ATTRS{idProduct}=="7028",MODE="0666"
其中的ATTRS{idVendor}=="1ebf",要写自己手机的,比如我的为18d1。
3、启动adb的服务
这个网上的经验是在adb工具的目录下执行,我是按照做的,成功。- cd ~/program/Android/sdk/platform-tools
- sudo ./adb kill-server
- sudo ./adb start-server
- sudo ./adb devices