Remote Debugging for Android Devices
Tags: reactnative, ios, android, tutorial
Published: 2022-04-20 08:03:47

While working on android applications development, it is a common practice to debug apps using a USB cable to connect the device to android studio. With the decreasing number of computer's ports, for which we require an external dongle device to connect USB cables. By using remote debugging, it saves a lot of time and space needed to carry external accessories used to debug a mobile application on an android device.

A couple years back I wrote an article on [**Remote Debugging in React Native**](https://dev.to/davidokonji/remote-debugging-in-react-native-3o72) which was majorly focused on using Xcode to connect to IOS devices remotely, at that time remote debugging option was not available for android studio.

In this article, I will be explaining how to set up remote debugging for an android application over the network using Android Studio and an Android device.

**Note:** This is not limited to testing a native android application but also for react native and flutter applications.

### Required Tools
- [Android Studio Bumblebee | 2021.1.1 Patch 3](https://developer.android.com/studio) or later
- A android device running on Android 11+
- A wireless connection common to both mobile phone and system running the android studio

### Steps to setup
Now, we have all tools setup, we can go ahead to open our android project in android studio and follow the steps below;

#### On the android test device
We should ensure the **Developer Options** is enabled, In developer options, an option for **Wireless debugging** should be toggled off by default, it should be toggled on

![Android wireless debugging on](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8v2msrqznk4gy2ftjsy.jpg)

Tapping on the enabled wireless debugging should get you options to connect wirelessly

![Android wireless debugging options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pffti0pyxojsxizgw75.jpg)

#### In android studio
We should click on the dropdown to select a device at the top right menu bar,

![Android Device selection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x26m9y6o2sazpctzzcxb.png)

That should give a pop up dialog which give a default option to **Pair using QR code**

-> **Pairing using QR code**

![Pairing using QR code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2b7efv53nom8jzjrcv9.png)
On the mobile device already been setup above, we click on the option to `Pair device with QR code` which gives a QR scanner screen to scan the QR generated by android studio

![Scan Android QR](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ewg4s87ea1w9ifbbhv8.jpg)

Once scanned correctly, we get a successfully paired status and would see the new paired devices under the list

![Successfully paired](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98neslb7soyc9r1uf4ol.jpg)

-> **Pairing using pairing code**
On the mobile device already been setup above, we click on the option to `Pair device with pairing code` to generate a pairing code which would be used to finish the pairing set up.

![Pairing using pairing code start](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhp9tclk160wkhslqj4m.jpg)

In android studio we should toggle the `Pair using pairing code` option in the popup dialog, we should see our device ready to start pairing

![Start Pairing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6z7rjoxgtb4qucpje3nk.png)

Input the code generated on the mobile phone into the fields on android studio

![Code input](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wi2olmv3t86y7uyvnrx1.png)

Once scanned correctly, we get a successfully paired status and would see the new paired devices under the list

![Successful](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4c2mw692ra0jsl4tpx83.png)

Either ways we go about pairing the device, once done we should see our device available for the app to run on anytime we are connected to the same network 🎉

![Run on device](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bb75xlrhp2tlf6wljznu.png)

### Debugging issues
- **Can't see developer options? How to toggle developer options on a new device:**
  Go to phone settings -> Scroll to the bottom and click on the about phone option -> Click on software information -> Tap on the `Build number` 7 times to get a prompt that developer options has been enabled.
- **Can't see device to pair with?**
Confirm if the android device and system running the android studio are on the connected to same network.

### Conclusion
Using remote debugging generally saves a lot of time to debug mobile applications, Hopefully it would save yours.

Thanks for reading 🥳