How to connect an Android device using adb?

premise

Prerequisites for using adb to connect to Android devices 1. Various hardware statuses are normal; 2. The USB cable of the mobile phone is intact and can transmit data;

There are two ways to connect adb to a mobile phone, which are divided into wired connection and wireless connection. The wired connection is to use a USB cable to connect to the mobile phone, and the wireless connection is to use WiFi to connect to the mobile phone.

wired connection

1. First, you need to enable the developer options of the Android device and allow USB debugging. Different mobile phone models have different ways to open the developer options. There are roughly two ways to open the developer options.

1) Turn on the phone and find [Settings] --> find the [System] column (some phones have more settings) --> select to open [Developer Options] and enable [USB debugging]

2) If you can’t find where the developer option is, you can find the developer option and open it as follows:

Turn on the phone and find [Settings] --> click [More Settings] --> click to enter [About Phone] --> find [Version Number] and click 7 times in a row to enable the developer mode

At this time, when the prompt [You are now in developer mode] appears at the bottom of the screen, it means that it has been turned on. If it does not appear, just keep clicking until it appears.

2. Connect the normal USB cable to the computer and the mobile phone. After the connection, a pop-up window will pop up on the mobile phone to select the connection method (only charging, transferring files, etc.), and select transferring files. After the driver is successfully installed on the computer, it can be done. Some devices may fail to install the driver on the computer, resulting in connection failure. At this time, you can install some assistants to successfully install the driver.

3. Win+R shortcut key, enter cmd to open the terminal window, enter: adb devices to check whether the connection is successful, if the device is displayed as shown in the figure below, it means the connection is successful, otherwise it is a failure.

Wireless connections

1. The wireless connection also needs to open the developer options of the Android device and allow USB debugging, and the mobile phone and the computer need to be in the same LAN.

2. First connect to the computer through a USB cable, and then enter adb devices to check whether the connection is successful.

3. After successful connection, enter the following adb command to set up mobile monitoring: adb tcpip 5555 , where 5555 is the port number, and this port number can also be customized

4. Next, you can unplug the USB cable, and then enter the following adb command to connect to the mobile phone: adb connect mobile phone IP + port number , and finally enter adb devices, and the device information can be viewed as shown in the figure below, which means adb wireless connection It worked.

If you want to disconnect, just enter adb disconnect

Problems you may encounter when using ADB to connect to your device

1. After the USB cable is plugged into the computer, ADB Intelface displays a yellow exclamation mark. When the installation of the driver device fails, for example, as shown in the figure below

Solution:

The solution is very simple, just open the browser and search for ADB Driver Installer to download and install. After the installation is successful, as shown in the figure below, then use the USB to connect to the computer again!

2. Use ADB to connect to the mobile phone wirelessly. In the step of entering adb connect mobile phone IP + port number, I don’t know when the mobile phone IP is.

Solution: Introduce two ways to know the IP of the mobile phone

Method 1: Open mobile phone settings --> open WLAN --> click on the right side of WLAN to enter the specific information (different mobile phones have different ways to view specific information of WLAN, as long as you can view the specific information), and finally display in the IP address That column is the IP we need to use.

Method 2: Directly enter the following command to view: adb shell ifconfig wlan0 , you can see that the IP that we need to use next is displayed in the column of inet addr

 

Guess you like

Origin blog.csdn.net/m0_64776928/article/details/125985233