Search code examples
androidadbandroid-sdk-tools

Change ADB port range


Using most emulators the ADB server will locate devices in the 5555-5585 range, every device uses 2 ports (console, ADB) which leaves a fairly small range.

Some emulators are using custom ports. MEmu seems to be scanning a completely different range (21503+).

How is MEmu doing this? How can I modify the port range that the ADB server is using to locate devices?

I've tried to scan devices yet none were found unless I ran the adb.exe that comes with MEmu. However it seems to be only working for MEmu instances. I've changed BlueStacks port to 21503 and ran MEmu's adb.exe yet no devices were found.

How comes it only works with MEmu?


Solution

  • adb uses this environment variable

    $ADB_LOCAL_TRANSPORT_MAX_PORT max emulator scan port (default 5585, 16 emus)
    

    to specify the maximum port number it scans.