Skip to content

Instantly share code, notes, and snippets.

@juniorcesarabreu
Forked from teocci/MultipleDevicesOverTCP.md
Last active January 23, 2019 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juniorcesarabreu/80ce7b56c00020325df9fe87ede1f9c6 to your computer and use it in GitHub Desktop.
Save juniorcesarabreu/80ce7b56c00020325df9fe87ede1f9c6 to your computer and use it in GitHub Desktop.
How to connect multiple Android devices with ADB over TCP

How to connect multiple Android devices with ADB over TCP

From your device, if it is rooted

According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands:

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

And you can disable it and return ADB to listening on USB with

setprop service.adb.tcp.port -1
stop adbd
start adbd

From a computer, if you have USB access already (NO root required)

1. For Linux and MAC User:

Step 1:

Open terminal and install adb using

sudo apt-get install android-tools-adb android-tools-fastboot

Step 2:

Connect your phone via USB cable to the PC. Type following command in terminal to get the device ID:

$ adb devices

List of devices attached
LGV498b9cacc1   device
192.168.1.187:5558      device
192.168.1.184:5557      device
192.168.1.186:5556      device
192.168.1.143:5555      device

Step 3:

Using the device name listed above, get the IP of your Android device (if you know you can skip this step)

$ adb -s LGV498b9cacc1 shell ip -f inet addr show wlan0

22: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    inet 192.168.1.185/24 brd 192.168.1.255 scope global wlan0

Step 4:

Setup the communication port using this command:

$ adb -s LGV498b9cacc1 tcpip 5559

restarting in TCP mode port: 5559

Step 5:

Connect to your Android device IP address.

$ adb -s LGV498b9cacc1 connect 192.168.1.185:5559

connected to 192.168.1.185:5559

Step 6:

Verify if the device was added to the list:

$ adb devices

List of devices attached
192.168.1.185:5559      device
LGV498b9cacc1   device
192.168.1.187:5558      device
192.168.1.184:5557      device
192.168.1.186:5556      device
192.168.1.143:5555      device

Now you can remove your phone.

2. For PC users:

Step 1:

Enable Developer options in your Android phone using this way.

  • Open Settings> About> Software Information> More.
  • Then tap “Build number” seven times to enable Developer options.
  • Go back to Settings menu and now you'll be able to see “Developer options” there.
  • Tap it and turn on USB Debugging from the menu on the next screen.

Step 2:

Open your cmd and type adb. If you find that the adb is not a valid command then you have to add a path to the environment variable.

  • First go to you SDK installed folder. Follow this path as an example. ```` D:\softwares\Development\Andoird\SDK\sdk\platform-tools; D:\softwares\Development\Andoird\SDK\sdk\tools; ```
  • Now search on windows system advanced setting
  • Open the Environment variable.
  • Then open the "PATH" variable and paste the previous example path to its variable value.
  • NOTE: You SDK path is different from mine please use yours. Now you can connect your android phone to PC.

Step 3:

Connect your phone via USB cable to the PC. Open cmd and type following command in terminal to get the device ID:

$ adb devices

List of devices attached
LGV498b9cacc1   device
192.168.1.187:5558      device
192.168.1.184:5557      device
192.168.1.186:5556      device
192.168.1.143:5555      device

Step 4:

Using the device name listed above, get the IP of your Android device (if you know you can skip this step)

$ adb -s LGV498b9cacc1 shell ip -f inet addr show wlan0

22: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    inet 192.168.1.185/24 brd 192.168.1.255 scope global wlan0

Step 5:

Setup the communication port using this command:

$ adb -s LGV498b9cacc1 tcpip 5559

restarting in TCP mode port: 5559

Step 6:

Connect to your Android device IP address.

$ adb -s LGV498b9cacc1 connect 192.168.1.185:5559

connected to 192.168.1.185:5559

Step 7:

Verify if the device was added to the list:

$ adb devices

List of devices attached
192.168.1.185:5559      device
LGV498b9cacc1   device
192.168.1.187:5558      device
192.168.1.184:5557      device
192.168.1.186:5556      device
192.168.1.143:5555      device

Now you can remove your device and run your Android project.

Multiple devices with ADB over TCP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment