Setting Up ADB Over Wi-Fi on Android 11+ for Windows: A Comprehensive Guide

Setting Up ADB Over Wi-Fi on Android 11+ for Windows: A Comprehensive Guide

21 May 2024 Stephan Petzl Leave a comment Tech-Help

Connecting your Android device to your Windows workstation via ADB over Wi-Fi can significantly streamline your development workflow. However, the dynamic port assignment can make the process cumbersome. This guide provides a step-by-step solution to maintain a fixed port and automate the connection process, ensuring a seamless experience.

Step-by-Step Instructions

Initial Setup

To get started, ensure that wireless debugging is enabled on your Android device.

  1. Go to Settings > System > Developer options.
  2. Enable Wireless debugging.

Fixing the ADB Port

To maintain a fixed port for ADB connections, follow these steps:

  1. Pair your device and connect using the dynamically assigned port.
  2. Open a terminal on your Windows workstation.
  3. Run the following command to set a fixed port (e.g., 5555) for ADB connections:
adb tcpip 5555

Now, you can connect to your device using the fixed port until the next reboot:

adb connect :5555

Automating the Connection

To automate the connection process, you can create a simple script. Here’s an example script for Windows:

adb connect :
adb tcpip 5555
adb disconnect
adb connect :5555

Save this script and run it whenever you reboot your device to reconnect automatically.

Alternative Solutions

Using Nmap for Dynamic Port Detection

If you prefer a dynamic approach, you can use Nmap to detect the port and connect automatically:

adb connect :$(nmap  -p 37000-44000 | awk "/\/tcp/" | cut -d/ -f1)

This command scans a range of ports and connects to the detected port. You can set this up as an alias for convenience.

Utilizing mDNS for Device Discovery

Android devices broadcast connection details over mDNS. You can discover and connect to these devices using tools like avahi-browse:

avahi-browse --terminate --resolve _adb-tls-connect._tcp

Once discovered, connect using the service name or IP and port:

adb connect 
adb connect :

Streamlining Test Automation with Repeato

While setting up ADB over Wi-Fi can enhance your development process, managing and automating tests can be challenging. This is where Repeato comes in handy. Repeato is a no-code test automation tool for iOS and Android, designed to simplify the creation, execution, and maintenance of automated tests for your apps.

Repeato allows you to execute ADB commands via script steps, enabling precise timing and sequencing of commands. This integration ensures that your test automation setup is efficient and reliable, significantly reducing the manual effort involved in managing ADB connections.

For more details on how Repeato can enhance your test automation workflow, visit our documentation or contact us for personalized support.

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