Steps to connect ubuntu with wifi to debug android

  • 2020-05-27 07:07:17
  • OfStack

Note: if you don't have the root permission, you can try it. In general, you need the root permission to connect successfully.

1. Make sure your development PC and Android phones are connected to wifi and under the same network segment;
2. Start debugging of usb and connect Android device to development PC with usb;
3. Go to your Android SDK platform-tools directory,
Execute the following command to restart the adbd daemon on the Android device and listen again on the specified port of TCP:
$./adb tcpip 5555
Note: 5555 is the default port, there is no need to replace it with another port, and here 1 must set 1 port!

4. Establish the wifi debug connection by executing the following command:
$./adb connect Android actual IP address of the device [: port number specified by./adb tcpip]
Note: there is a colon between the IP address and the port number, which can be omitted if the port number is 5555.

If an error message such as "unable to connect to IP address: port number "appears, then:
1) enter the Android device terminal:
$./adb shell

2) switch root user to Android device:
$ su -

3) set the specified port number of adbd service:
# setprop service.adb.tcp.port 5555
Note: although 5555 is the default, here also want to set 1, can also be customized, but what is necessary.

4) after setting up adbd service, rerun it:
# start adbd
Note: the # stop adbd command will stop adbd and only restart the Android device.

5) restart the adbd daemon in the Android device and listen to the specified port of TCP again:
$ ./adb tcpip 5555

6) establish the wifi debugging connection:
$./adb connect IP address [: port number]

7) the following words appear to indicate success:
connected to IP address [: port number]

8) enter the Android device terminal:
$./adb shell

9) execute the netstat command, and you can see the status where the IP address: port number has been established:


Proto Recv-Q Send-Q Local AddressForeign AddressState
tcp00 0.0.0.0:5555 0.0.0.0:*LISTEN
tcp00 0.0.0.0:110000.0.0.0:*LISTEN
tcp 260 192.168.1.104:5555 192.168.1.102:40821ESTABLISHED
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Proto Recv-Q Send-Q Local AddressForeign AddressState
tcp00 0.0.0.0:110000.0.0.0:*LISTEN
 Note: dividing line (---) The one above is the established status display, and the one below is the unestablished status display. 
9) Execute view device command results, also with  usb  The different: 
$ ./adb devices
List of devices attached 
192.168.1.104:5555 device
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - 
List of devices attached 
android123456 device

Note: the separation line (--) above is the TCP connection and below is the usb connection.

*. Restart the adbd daemon on the Android device and listen for usb again by executing the following command:


$./adb usb

Note: after executing this command, the device cannot be checked by using./adb devices to view the device.
$sudo./adb kill-server and $sudo./adb start-server
You can only restart the Android device!

So, the right thing to do is:
1) enter the Android device terminal:
$./adb shell

2) root users switching to Android devices:
$ su -

3) set the specified port number of adbd service:
# setprop service.adb.tcp.port -1
Note: to turn off wifi debugging, simply set the port number to -1 (-1) here.

4) after the above three steps are completed, you can execute./adb usb to cut back to usb connection debugging mode.

* note: if you just disconnect 1, just run the following command:
$./adb disconnect


Related articles: