With Broken USB Cable, How to Debug the App: Wireless Connect 😏
Tags: android, beginners, programming
Published: 2022-09-28 17:51:09




You are working nonstop to be promoted to Senior App Developer for months and this app project is the ladder to take you a step closer to it. But at the last moment, you broke your ladder. Goddd! Why me?? Sings in a corner _"Give me some sunshine, give me some rain, give me another chance I wanna buy a USB cable once again"_ 

## Why not use Virtual Device? 🤔

Developing an app on a low-end laptop is truly annoying. There is already low RAM, and now you have to allocate some for the virtual device, thus making us stare at **(Not Responding)** added to the window title more than actually coding. We can’t just keep wasting our time like this, right? Especially when the project deadline is close and other clients keep nudging you to finish their projects. So we opt to connect our mobile phones with a USB cable and run the app on them. But this brings us to another problem! 

## What is the Problem With Using Cables? 🤯

Managing the cables and wires and wires and some more wires while working is a big headache. There is the charger cord, a wired keyboard, a wired mouse, your Wi-Fi dongle and maybe some other indispensable device, and then your mobile device to run the simulation. Product designers, following the "*less is more*" mantra, are ruthlessly reducing the number of ports on a laptop now. Dude, *less is more* for design, not functionality!!

Now there are fewer and fewer ports and more and more devices to connect to. Facing this crisis, we can do nothing but sacrifice for the greater good, especially when I am the chosen one and my laptop’s USB port/cable stops working (your name will be remembered in some GitHub repositories).

## I wish I could connect my device without any cables! 🙏🏻

Did I accidentally rub a genie lamp or what? There is actually a way to do wireless debugging! 

I should have wished for my Hogwarts Invitation Letter instead!

While browsing through the developer options on my newly bought phone😌, I came across a new option… Wireless Debugging! Now I don't have to open the Amazon app to order a USB cable anymore. ✌️

## Okay, so how do we Debug ‘*Wirelessly*’? 😌

- First of all, you have to turn on developer options. Go to **About Phone > Version** and click on “*Build Number”* 7 times. *Woohooo*! You're a developer now!

![Turn On Developer options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0kbk97bfgkm8q3kegc0o.jpeg)

- Now **Connect your device** to your laptop with a USB cable and select *file transfer mode* ( while initializing for the first time, you still need a USB cable😞, but just for the first time and no more 😃).

![USB cable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qibv7n2t2bj3uvcszqw0.png)



- Make sure both your devices are connected to the **same Wi-Fi network** and ARE **DISCOVERABLE**.
    
    You can **ping your device** to confirm it. Enter your mobile’s IP Address.
    
    **Note:** To **find your device's IP address**, you can simply click on *Wireless Debugging* or go to **About Phone > Status.**
    
    ```powershell
    ping 192.168.x.xxx
    ```
    

![Ping mobile IP response](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkgxzh9n3jpi4lzjqke9.jpeg)

Yayyy!! We are connected now.

- Now go to developer options and **turn on *USB Debugging*** and allow debugging.
- **Turn on Wireless debugging**, and a pop-up will appear asking you to confirm the network and device ID. Click "Allow.”

![Turn on USB Debugging and Wireless Debugging](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ur9t9dhfk8hak0ogwnp.jpeg)

- Now **open your terminal** and navigate to the folder containing ***adb.exe*** in ***Android SDK platform tools.***
- If you don't know the ***adb.exe*** file location, Open **Android Studio**, **Tools > SDK Manager**

![Open SDK Manager](https://res.cloudinary.com/practicaldev/image/fetch/s--s2SpjJx5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86as35m6jwr4ync3b6vt.png)

- Copy the ***Android SDK location***

![Copy Android SDK location](https://res.cloudinary.com/practicaldev/image/fetch/s--IgFc1DdU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13vxxc22221ja8oen725.png)

- Navigate to the **Android SDK platform tools** in the terminal.

```powershell
cd C:\Users\91825\AppData\Local\Android\Sdk\platform-tools
```

![Navigate to platform tools](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1oa22t2ozupn18gpj5oa.png)



- First, **kill the current server** to avoid issues because of the running server.

```powershell
.\adb kill-server
```

![ADB kill server](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ldoixqkqz99ntp43a7l4.png)



You will see another pop-up on your device to allow debugging. Click "Allow.”

- Next, set the debugging port to **5555**.

```powershell
.\adb tcpip 5555
```

![adb tcpip 5555](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jo9x5wmm4gncwb1hkor.png)


Once again, click allow on the popup on your device.

- The next and final step is to **connect**

```powershell
.\adb connect 192.168.x.xxx
```

![Connect the device](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/znfkgiipww7nextg1qdi.jpeg)



**PS:** When you click enter it will prompt *failed to authenticate*. Worry not my friend, once you allow the popup on your device, and repeat the same command, it will say *already connected.*

Now you can 'dis-entangle' your USB cable and put it back into your drawer. You are all set to work now.

### Let’s catch up for a beer 🍻

Connecting devices wirelessly reduces the hassle of managing wires and also saves us a lot of time as we don’t have to use virtual devices. Now that we've got spare time on our hands, let’s use it for another project, or maybe connect on [LinkedIn](https://www.linkedin.com/in/divyamojas/).

**PS:** I've tested this method for Windows + Android Mobile, will this work for Linux + Android too? Or Windows + iOS?  

> If you run an organization and want me to write for you, please do connect with me. 😃