Search code examples
androidadb

Maximum number of devices connected to an ADB server


According to Android Debug Bridge :

The server then sets up connections to all running emulator/device instances. It locates emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the range used by emulators/devices. Where the server finds an adb daemon, it sets up a connection to that port. Note that each emulator/device instance acquires a pair of sequential ports — an even-numbered port for console connections and an odd-numbered port for adb connections. For example:

Emulator 1, console: 5554

Emulator 1, adb: 5555

Emulator 2, console: 5556

Emulator 2, adb: 5557 ...

The ADB server only checks for devices by scanning odd-numbered ports in the range 5555 to 5585 ( 30 ports in total) and assigns 2 ports for each device. Is ADB capable of accepting more than 15 Android Devices (15x2 ports) or can I connect more devices on the same computer? I think it is impossible to run more than one ADB servers on the same machine.


Solution

  • You can run more than one instance of adb on the same computer using the environment variable ANDROID_ADB_SERVER_PORT. see more details on this answer.

    With the -ports option on the emulator, you can specify any port, and then do:

    $ adb connect localhost:PORT
    

    If your phone is rooted you can restart adbd on another port (see another answer), and then:

    $ adb connect IP_OF_DEVICE:PORT
    

    The device is then available over wifi and does not need to be plugged in. Be aware that anyone on your wifi network can access your phone this way!