Tools

In virtualized systems, the device can have multiple VMs with each running its own ADB daemon. In this case, the host VM can export an RNDIS Ethernet gadget, which can be used for the TCP/IP-based communications over the USB physical link. The development machine can then use ADB over TCP/IP to access multiple VMs on the device. The ADB daemon on the host side can announce the ADB presence on the guest VMs over mDNS by publishing ADB services. In addition, the development machine can browse these services with ADB tool, which supports mDNS device discovery (ADB version 31.0.2 or later) to get the IP address and the port number on which adb daemon is listening and then connect to the guest VMs.

The following commands can be used on the development machine to browse and connect to the ADB services.

  1. To enable mDNS discovery, run:
    export ADB_MDNS_OPENSCREEN=1
    adb kill-server
    adb start-server
    
  2. To discover ADB services, run:
    adb mdns services
    
    List of discovered mdns services
    driver_vm	_adb._tcp	192.168.1.49:4444
    device_vm	_adb._tcp	192.168.1.49:3333
    
  3. To connect to the device, run:
    adb connect driver_vm._adb._tcp
    
  4. To list the connected devices, run:
    adb devices
    
    List of devices attached
    driver_vm._adb._tcp device