The solution to the problem that adb cannot connect to the device.
First make sure the version on your computer matches the version android-platform-tools
on your device API
.
$ adb --version
Android Debug Bridge version 1.0.40
Version 4986621
Installed as /usr/local/Caskroom/android-platform-tools/28.0.1/platform-tools/adb
adb
For example, above, the version of my computer is 28
connected to a 10.0
system ( API 29
) device, but it cannot be connected alive or dead. . .
So when you encounter a device that cannot be connected, check or try to update adb
the version first to ensure that the version can match.
Version matching reference Android SDK
# brew 更新 adb 命令
$ brew upgrade android-platform-tools
If you still can't connect, the usual solution:
- Re-plug the data cable;
- Turn off the developer options again , plug and unplug the data cable;
- Turn off USB debugging again , plug and unplug the data cable;
- Revoke the USB debugging authorization, plug and unplug the data cable.
don't show device
The mobile phone and the computer have been connected through a data cable, but the device number is not displayed.
$ adb devices
List of devices attached
* daemon not running; starting now at tcp:5037
* daemon started successfully
In this case, first check whether the device is actually connected to the computer, and execute the following command.
$ system_profiler SPUSBDataType
...
ELE-AL00:
Product ID: 0x107e
Vendor ID: 0x12d1 (Huawei Technologies Co., Ltd.)
...
After executing the command, if the device information is not found in the output, then replace the USB data cable and try again.
Record the device Vendor ID
and add it to adb_usb.ini
the file, if there is no such file, create a new one.
$ vim /Users/用户名/.android/adb_usb.ini
Unplug the device and try again.
unauthorized
The connected device is displayed, but the device is in unauthorized
the state, and the mobile phone does not display the authorization prompt box.
$ adb devices
GBG5T19731003744 unauthorized
The pop-up box of not popping up the authorization may be that there is a historical authorization record of this phone on the computer. Even if the authorization fails, the pop-up window will not pop up again.
$ cd /Users/用户名/.android/
$ rm adbkey adb_usb.ini
Delete the above two configuration files, plug and unplug the device and try again.