Connecting to Android Devices Using ADB Over TCP

Connecting to Android Devices Using ADB Over TCP

30 November 2024 Stephan Petzl Leave a comment Tech-Help

Debugging Android applications often involves using the Android Debug Bridge (ADB) to connect to devices. While USB connections are straightforward, there are situations where connecting over a network becomes necessary, especially when physical access to the device is limited or when using virtual machines. This guide will provide a step-by-step approach to connect your Android device using ADB over TCP.

Why Use ADB Over TCP?

Connecting to Android devices over TCP can be beneficial in several scenarios:

  • When the development machine is a virtual environment without direct USB access.
  • To facilitate remote debugging without physical access to the device.
  • When testing multiple devices without switching USB connections.

Steps to Connect ADB Over TCP

Pre-requisites

  • Ensure both the development machine and the Android device are connected to the same Wi-Fi network.
  • Make sure ADB is installed on your development machine and is accessible via the command line.
  • Enable USB debugging on your Android device via Developer Options.

Connection Process

Step 1: Connect via USB

Initially, connect your device to the development machine using a USB cable to establish a reliable ADB connection.

Step 2: Enable TCP Mode

Open a command prompt or terminal on your development machine and execute the following commands:

adb tcpip 5555

This command restarts ADB in TCP mode on port 5555.

Step 3: Find Your Device’s IP Address

To find the IP address of your device, you can either:

  • Navigate to Settings > Wi-Fi > Advanced on your Android device.
  • Run the following ADB command:
adb shell ip -f inet addr show wlan0

Step 4: Connect Over Wi-Fi

With the IP address obtained, disconnect the USB cable and use the following command to connect over Wi-Fi:

adb connect :5555

Replace <DEVICE_IP_ADDRESS> with the actual IP address of your device.

Step 5: Verification

To ensure a successful connection, run:

adb devices

Your device should appear in the list as connected over TCP.

Returning to USB Debugging

Once you are done with TCP debugging, you can switch back to USB mode using:

adb usb

Leveraging Repeato for Efficient Testing

If you’re involved in mobile app testing, using a tool like Repeato can streamline your testing process. Repeato is a no-code test automation tool for iOS and Android that simplifies the creation, execution, and maintenance of automated tests. Its integration with ADB allows you to execute ADB commands seamlessly, making it ideal for scenarios where precise timing and command sequences are critical. With computer vision and AI capabilities, Repeato ensures fast and efficient testing cycles.

For further guidance on setting up virtual test devices or running test batches, explore our documentation.

Like this article? there’s more where that came from!