Monday, February 21, 2011

Debugging Android apps remotely via Wifi

Android has tonnes of cool features and this is just one of them. Now I don't need to search for my USB cable to start developing/debugging the apps. Also, poor Samsung, my WinXP BSODs whenever I plug out my phone from adb debugging. This was irritating and that's when I came across this useful tweak.

Requirements:
+ You need a root'ed Android phone. (I suppose, to start/stop services..)
+ You need a terminal emulator software on the phone (preferrably). Android market gives it free.
+ You should already have a working debugging setup from your PC to the phone via USB (I mean all those SDK's, tools, ADT plugin installed).

Connect your phone via Wifi into a n/w that provides access to, from your PC.

On the phone: (either via a 'terminal emulator' OR via 'remote ssh' OR via 'adb shell on USB')

$ su
# setprop service.adb.tcp.port 6666
# stop adbd
# start adbd

All set, now the adbd knows it is suppose to listen on TCP instead of USB.

Disconnect the USB if connected.

On the PC: (example on Windows)
C:\>adb devices

if this shows your device connected, run
c:\>adb disconnect

Then,
c:\>adb connect mobile_ip_address:6666
Connected to device mobile_ip_address:6666
[not to mention, you can use any port other than 6666, but use the same in both places.]

c:\>adb devices
[this should list your device.]

All set. Use Eclipse and debug just like you would on a USB connected device.

Note: This change goes off once you restart your phone. You can automate this in a number of ways.. left to you.

Seeing my apps getting deployed wirelessly onto my phone and debugging and watching those variables remotely is really cool!! :)

5 comments:

  1. Nice.

    What kind of app are you writing?

    ReplyDelete
  2. Nothing special right now. Just writing different proof-of-concept/sample apps, widgets to get used to thinking in android. The last one was a calendar appwidget to my homescreen.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. wow..its really nice blog. nice article..

    ReplyDelete
  5. Thank you very much! I was figuring out how this could be done without installing adbWireless or similar apps... :)

    ReplyDelete