adb network connection to Android device failed

1. Problem: cannot connect to 192.168.1.102:5555: Cannot connect because the target computer actively refuses. (10061)

First, make sure that the network of your computer and the network of the Android device to be debugged are in the same network segment (connected to the same wifi or router)

You can use the ping command to test, for example: after entering the ping 192.168.1.102:5555 command, if the amount of lost data is less than 100%, it is normal, indicating that the network is connected. (Note: 192.168.1.102 is the ip address of the Android device, not the ip of the computer, make sure not to make a mistake)

 Solution:

  1. Connect the Android device and computer with a USB cable.

  2. Turn on the usb debugging mode in the developer options of the Android device.

  3. Enter adb devices, if you can see the Android device that needs to be connected, it means that the connection has been successful through usb.

  4. Enter the following two commands one after another:

     adb root //Get root permission

     adb shell //Enter the shell of the Android system

  5. After entering the Android system, enter the command:

     setprop service.adb.tcp.port 5555 //Set the adb service port to 5555, open the adb network debugging function

     Other command instructions: setprop service.adb.tcp.port -1 //Indicates to enable the usb debugging function of adb. 

  6. Enter the exit command to exit the android shell.

  7. Enter the command:

     adb tcpip 5555 //Make the device listen for TCP/IP connections on port 5555.

  8. Unplug the usb cable, use the command adb connect 192.168.1.102 to connect to the adb network, and it can be connected normally.

  9. If it still does not work, it is recommended to turn off the usb debugging mode of the developer option of the Android device, and then turn it on again, or restart the Android device and then enter the command adb connect 192.168.1.102 to connect to the adb network

Guess you like

Origin blog.csdn.net/hnjcxy/article/details/126989388