As an Android developer, I'm spoiled. I depend on my IDE, logcat, and most of all, the Android Debug Bridge (adb). The adb can be run from a command line or directly in Eclipse. It allows me to load applications and see real-time console output; most importantly, it gives me the ability to set break points and single step through my code. The standard regiment is to enable debug on the phone or tablet, install the necessary drivers on the PC, and connect the device via a USB cable.
But what happens when you can't connect the device via a USB cable? Say, for example, the application you're writing uses the USB port to connect to an external device like a card reader or a game controller. This is the scenario I found myself in recently.
When I complained about my predicament to a buddy who also happens to be an Android developer he asked, "Why don't you run adb over TCP?" I responded, "You can do that?" The answer it turns out is a resounding yes. In just a few minutes, he had me up and debugging over my wireless connection. I've outlined the steps below.
- Open a command prompt and navigate to the directory where your copy of ADB.exe lives.
- Type "adb tcpip 5555" and press Enter.
- Type "adb connect 188.8.131.52:5555", replacing the 184.108.40.206 with your phone or tablet's IP address. Press Enter.
You should be able to do anything over the Ethernet that you were doing over a USB cable before. The only caveat is at least over wireless adb is a little sluggish. If you've ever tried to debug a USB device though from logs retrieved post mortem, you know a slightly slower adb connection is a small price to pay.
When you're ready to switch back over to USB, connect the USB cable to the device first, type "adb USB", and
William J Francis began programming computers at age eleven. Specializing in embedded and mobile platforms, he has more than 20 years of professional software engineering under his belt, including a four year stint in the US Army's Military Intelligence Corps. Throughout his career William has published numerous technical articles, as well as the occasional short story.