jackyalciné

Need a hand with tech consulting? I can help!
Learn more about how we can work via black.af .

The ecosystems of the world are dying.
Reduce your :pig::chicken: meat and :cow::goat: dairy intake to help the environment :seedling: .

This site is in the process of moving to Koype. You can view my instance at v2.jacky.wtf.

Remote Debugging with Android

Stop debugging with your phone plugged in!

:pencil: by Jacky Alciné Jacky Alciné :book: an android post :bookmark: android , debugging , tips :clock7: written :eyeglasses: about 2 minutes, 405 words :link: Comments - 0 Mention(s) - Permalink

If there’s one thing that plagues a developer at times, it’s the number of cables we have hooked up to our machines. Laptops, phones, tablets, watches, you name it! Even chargers for our chargers. I’m out to solve one of those problems and it helps when you’re doing some interactive Android development.

The Android debugging bridge tool (aka adb) is a super nifty tool that allows you to manage your devices, emulated or physical. A powerful use of it is the ability to handle all of its communication over TCP, a state aware means of transporting packets of data over IP. Using a device over TCP allows you to decouple the cable from your laptop or working station and move around with said device much more freely, making it easy to build and test gyroscopic applications, for example.

Getting Started

Ironically, the first thing you’d have to do is plug your device to your station of choice. Check if it’s visible to adb by running the following:

$ adb devices
List of devices attached 
<hexadecimal number of device>

If you see no devices listed, please ensure that USB Debugging is enabled on your Android device.

After that, connect both devices to a WiFi network. Go into your Android device and make note of the IP address it has. You can find this under Settings > WiFi > Options - Advanced at the field “IP address”.

Connecting to the Device

With that knowledge, and your Android device still plugged in, let’s set the device’s debugging tool to listen over TCP on port 5555:

$ adb tcpip 5555

I’ve seen that you’d need administrative privileges if you’re running Windows, check out this question for more information.

From here, you can (and should unless you’re charging over USB) remove your Android device from your laptop. We’d finish up the connection by connecting to the device over the network.

$ adb connect 0.0.0.0
# Replace 0.0.0.0 with the device's IP you found earlier.

That’s all there is to it! You should now be able to find this device in Eclipse or Android Studio for debugging now. If any more questions come up, try asking someone in #android-dev on Freenode or sending an email to the mailing list over at Google Groups.

Happy hacking!

Need a hand with tech consulting? I can help!
Learn more about how we can work via black.af .

The ecosystems of the world are dying.
Reduce your :pig::chicken: meat and :cow::goat: dairy intake to help the environment :seedling: .

This site is in the process of moving to Koype. You can view my instance at v2.jacky.wtf.