android applicaiton debug over wi-fi

Debugging Your Android Application Over Wi-Fi

Burak Dönmez
Android Debugging

--

Debugging an Android application is a crucial part of the development process, and while using a USB cable is the most common method, it can sometimes be restrictive and cumbersome. A more flexible approach is to use Wi-Fi for debugging. In this blog post, we’ll guide you through the steps to set up and debug your Android application over a Wi-Fi connection using Android Debug Bridge (ADB).

Prerequisites

  • Android Studio installed
  • A USB cable for initial setup
  • A computer and an Android device connected to the same Wi-Fi network
  • A basic Android application project

Try RobotQA cloud based device farm for debugging for free:

Link: Github

Step 1: Enable Developer Options on Your Device

  1. Open Settings: Navigate to the “Settings” menu on your Android device.
  2. About Phone: Scroll down and tap on “About phone”.
  3. Build Number: Find the “Build number” entry and tap it seven times. You’ll see a message saying “You are now a developer!”.
  4. Developer Options: Go back to the main “Settings” menu, and you’ll now see “Developer options” listed.

Step 2: Enable USB Debugging

  1. Open Developer Options: Go to “Settings” > “Developer options”.
  2. Enable USB Debugging: Scroll down and toggle on “USB debugging”.

Step 3: Connect Your Device via USB

  1. Connect via USB: Connect your Android device to your computer using a USB cable.
  2. Authorize Device: If prompted on your device, authorize the connection by checking “Always allow from this computer” and then tapping “OK”.

Step 4: Enable Debugging Over Wi-Fi

  1. Open Terminal: Open a terminal (command prompt or shell) on your computer.
  2. Connect Device via USB: Ensure your device is connected via USB and recognized by ADB:
adb devices

You should see your device listed.

3. Get Device IP Address: On your device, go to “Settings” > “About phone” > “Status” > “IP address” and note down the IP address.

4. Enable TCP/IP Mode: In the terminal, enter the following command to enable ADB over TCP/IP on port 5555:

adb tcpip 5555

5. Connect Over Wi-Fi: Now, connect to your device using its IP address:

adb connect <device_ip_address>:5555

Replace <device_ip_address> with the IP address you noted down.

6. Verify Connection: Check that your device is connected over Wi-Fi:

adb devices

You should see your device listed with the IP address.

Step 5: Disconnect USB

  1. Unplug USB Cable: You can now disconnect the USB cable. Your device will remain connected via Wi-Fi for debugging.

Step 6: Debug Your Application in Android Studio

  1. Open Your Project: Launch Android Studio and open your project.
  2. Select Device: In the toolbar, click on the device drop-down menu and select your connected device (now showing as an IP address).
  3. Run the App: Click the “Run” button (green play icon) to install and start the application on your device.
  4. Set Breakpoints: In your code, click in the gutter next to the line numbers to set breakpoints where you want to pause execution.
  5. Debug Mode: Click the “Debug” button (green bug icon) to start debugging.

Troubleshooting

  • Device Not Listed: Ensure both your computer and Android device are on the same Wi-Fi network. Retry the connection steps.
  • Connection Drops: Wi-Fi connections can be less stable than USB. If the connection drops, you may need to reconnect using the above steps.
  • Firewall Issues: Ensure your firewall settings allow ADB connections.

Additional Tips

  • Reconnect Automatically: You can create a script to automate the connection process each time you start debugging.
  • Use Static IP: Assign a static IP address to your Android device to avoid having to check the IP address each time.

Conclusion

Debugging over Wi-Fi can significantly enhance your development workflow by providing flexibility and reducing cable clutter. By following these steps, you can set up and debug your Android applications wirelessly, making your development process smoother and more efficient.

Feel free to leave comments or ask questions if you encounter any issues. Happy debugging!

--

--

Burak Dönmez
Android Debugging

Sharing experiences about mobile test automation. cofounder @roboticmobi