1 將測試機和開發機通過usb連接
2 通過命令查看usb連接情況
lsusb
會將當前usb連接情況展示出來
- Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
- Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
- Bus 006 Device 002: ID 17ef:6019 Lenovo
- Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
- Bus 005 Device 002: ID 0461:4e04 Primax Electronics, Ltd
- 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 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
- Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
3 查找你的手機所連接端口的ID
由於現在我的電腦上沒有連接Android真機,所以無法找到,如果連接了,以第三行的lenovo為例,如果確定這個是你的測試機,那麼讀取ID為:17ef
4 創建android真機的usb規則
sudo gedit /etc/udev/rules.d/android.rules
以上面聯想為例,ID為17ef為例,輸入下面這一行
SUBSYSTEM=="usb", SYSFS{idVendor}=="17ef", MODE="0666"
如果你換測試機,還可以把下面所有型號全部輸入,就不用每次都重復工作。如下:
- #Acer 0502
- SUBSYSTEM=="usb", SYSFS{idVendor}=="0502", MODE="0666"
- #Dell 413c
- SUBSYSTEM=="usb", SYSFS{idVendor}=="413c", MODE="0666"
- #Foxconn 0489
- SUBSYSTEM=="usb", SYSFS{idVendor}=="0489", MODE="0666"
- #Garmin-Asus 091E
- SUBSYSTEM=="usb", SYSFS{idVendor}=="091e", MODE="0666"
- #HTC 0bb4
- SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
- #Huawei 12d1
- SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", MODE="0666"
- #Kyocera 0482
- SUBSYSTEM=="usb", SYSFS{idVendor}=="0482", MODE="0666"
- #LG 1004
- SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", MODE="0666"
- #Motorola 22b8
- SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"
- #Nvidia 0955
- SUBSYSTEM=="usb", SYSFS{idVendor}=="0955", MODE="0666"
- #Pantech 10A9
- SUBSYSTEM=="usb", SYSFS{idVendor}=="10A9", MODE="0666"
- #Samsung 04e8
- SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"
- #Sharp 04dd
- SUBSYSTEM=="usb", SYSFS{idVendor}=="04dd", MODE="0666"
- #Sony Ericsson 0fce
- SUBSYSTEM=="usb", SYSFS{idVendor}=="0fce", MODE="0666"
- #ZTE 19D2
- SUBSYSTEM=="usb", SYSFS{idVendor}=="19D2", MODE="0666"