adb wireless connection device for debugging operation (Wi-Fi connection)

adb connectThe command uses the TCP/IP protocol to connect

1. Turn on the USB debugging function in the phone settings

(Some mobile phones can also restrict whether remote debugging is allowed. If this option exists, it needs to be turned on).

 

2. Connect the mobile phone and PC to the same network (connect to the same WIFI).

3. Use USB to connect the phone to the computer.

4. Use adb devicesthe command to check the device connection

 255d50d7

5. Use adb tcpipthe command to specify the tcpip port of the mobile device on the computer side

adb tcpip 5555

adb -s 255d50d7 tcpip 5555

Port 5555 is the default port, and other ports can also be used. -s is the parameter to operate the specified device in adb. -s 255d50d7 is to specify to perform this operation on the device 255d50d7. If only one device is connected, this parameter can be omitted.

 

6. Disconnect the USB connection between the phone and the PC

7. Check the IP of the mobile phone after connecting to Wi-Fi

Click WLAN in the settings, click the details of the connected Wi-Fi, and you can see the IP after opening

 

8. Use adb connectthe command to connect the phone to the computer

adb connect 192.168.3.142:5555

192.168.3.142 is the ip of your mobile phone after connecting to WIFI. The mobile phone and computer need to be in the same network environment (as long as a wired network is also available in a local area network)

There is a problem here, the connection cannot be made, and there is no response; after waiting for a long time, the prompt: failed to connect to '127.18.176.181:5555': Operation timed out

Query possible reasons:

(1) It is possible that port 5555 is occupied

Check if the port is occupied

lsof -i:5555

port is not used

(2) Check the IP address, the IP address may change

(3) Restart the adb service

adb kill-server
adb start-server

  (4) On Huawei devices, turn on "Allow ADB debugging in charging mode only"

(5) Disable USB debugging and enable it again

(6) Turn off the WIFI on the mobile phone, then turn it on again, and try to connect again.

(7) Start adb in administrator mode

sudo adb start-server

  (8) Set the adb service port to 5555, and open the adb network debugging function

adb root 获取root权限

#提示adbd cannot run as root in production builds

#adb shell "su -c ' cd data; cd data; ls '"

setprop service.adb.tcp.port 5555

stop adbd

start adbd 

(9) First pair your device with your machine via adb

adb pair <IP:PORT>

On Device > Developer Options > Wireless Debugging > select Pair device with pairing code

Enter this pairing code into the console and the devices will be paired.

Now use adb connect <IP:PORT>

(10) Restart the device

(11) Computer pings mobile phone

To make sure it's not in network idle mode, unlock the device and even try surfing to some websites just to get it out of network idle.

(12) When the device is connected via USB, try to switch the USB connection mode to MTP/PTP/Camera, and then repeat these steps.

8. Use adb devicesthe command to check the device connection

9. When multiple devices need to be connected, the above operation can be repeated, but the port number needs to be slightly modified and cannot be repeated .

It should be noted that if a mobile phone is connected to the PC through USB and tcpip at the same time, adb devices will recognize two devices, but they are actually two connection methods of the same mobile phone.

10. When the device connection is no longer needed, you can use adb disconnectthe command to disconnect

adb disconnect 172.18.176.181:5555

11. Switch between USB connection mode and wireless debugging mode

adb usb 切换到USB模式

adb tcpip 5555 切换到WIFI无线调试

At present, I have tried all the methods mentioned above, but I still cannot connect successfully. The computer will fail to ping the mobile phone, and the pairing code will also fail. Has anyone solved this problem before? Welcome to provide solutions~

Mac computer, mobile device is oneplus9, Android11.

 

Guess you like

Origin blog.csdn.net/Vermouth_00/article/details/131088485