在安卓开发中,新拿到的开发设备如果连接到计算机以后,使用adb devices为空的话一般需要重新配置以下,步骤如下
1.打开开发者选项
首先确保手机的开发者选项打开,并且USB调试选项也打开
2.查看USB设备ID
首先拔掉USB设备,输入lsusb查看设备列表
>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 004: ID 3044:4eec
Bus 003 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 003 Device 002: ID 0bda:c811 Realtek Semiconductor Corp.
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
然后插上USB设备,输入lsusb和上面的列表对比得到插入设备的ID(多出来的那一行)
>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 004: ID 3044:4eec
Bus 003 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 003 Device 002: ID 0bda:c811 Realtek Semiconductor Corp.
Bus 003 Device 061: ID 05c6:9091 Qualcomm, Inc.
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
此处既是倒数第二行
Bus 003 Device 061: ID 05c6:9091 Qualcomm, Inc.
3.添加到配置文件
将上面获得的ID添加到以下配置文件中
05c6 为vendor ID
9091 为product ID
sudo vim /etc/udev/rules.d/51-android.rules
ATTR{idProduct}=="4ee0", SYMLINK+="android_adb", MODE="0660", GROUP="plugdev", TAG+="uaccess", SYMLINK+="android"
ATTR{idProduct}=="d00d", SYMLINK+="android_adb", MODE="0660", GROUP="plugdev", TAG+="uaccess", SYMLINK+="android"
ATTR{idProduct}=="9091", SYMLINK+="android_adb", MODE="0660", GROUP="plugdev", TAG+="uaccess", SYMLINK+="android"
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTRS{idProduct}=="6860", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", ATTRS{idProduct}=="9091", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", ATTRS{idProduct}=="901d", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="2717", ATTRS{idProduct}=="ff40", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", ATTRS{idProduct}=="f003", MODE="0666", GROUP="plugdev"
再将vendor ID 05c6添加到以下配置文件
cd ~
sudo vim .android/adb_usb.ini
0x04e8
0x05c6
4.重启adb服务
adb kill-server
adb start-server
然后输入adb shell/devices就应该可以看到设备了