Troubleshooting ADB connections to Starnix

This page provides troubleshooting tips for making an ADB connection to Fuchsia devices.

If you cannot use the adb command to connect to your Fuchsia device over USB, you can connect to an Android instance running inside Starnix using TCP port forwarding:

  1. In one terminal, forward a host port to the device's ADB port (5555):

    ffx forward "HOST_PORT=>5555"

    Replace HOST_PORT with an available port on your machine (for example, 5559).

  2. In a second terminal, connect the ADB server to that host port:

    adb connect localhost:HOST_PORT

However, there are a few ways this setup can fail to work, and this page includes guidance for addressing common issues.

Make an ADB connection to an emulator

For making an ADB connection to the Fuchsia emulator (FEMU), you can run the following command instead:

ffx starnix adb connect

This command enables adb to connect to your Fuchsia emulator using TCP and makes use of a network address provided by ffx for the connection.

Multiple adb devices

When multiple Android devices are connected to your development machine or when the Android device is running in an emulator, you may see an error from adb that multiple devices are present and it doesn't know which one to use.

To verify if your development machine's ADB server sees multiple devices, run the following command:

adb devices -l

If the output lists multiple devices, you need to specify a target device for your adb commands. The identifier for the device connected via port forwarding is the address you used in the adb connect command (for example, localhost:5559).

You can pass this identifier as an argument to your adb commands using the -s flag, for example:

adb -s localhost:HOST_PORT shell ls

Alternatively, you can set it as the ANDROID_SERIAL environment variable, which will be used by subsequent adb commands:

export ANDROID_SERIAL=localhost:HOST_PORT

Once this environment variable is set, you can use adb commands normally.