INVISIBLE HEADING 1

Debugging Your Android App Wirelessly on an Android Smartphone

March 16, 2011 8:20 pm by
adb

Introduction

Developing for Android is very easy to set up and get started on your computer.  However, a gripe shared among others, not just me, is that the Android emulator is too slow.  On my old computer, it would take 1-2 minutes for it to boot up.  In debugging mode, the response time is very slow.

There are two methods:

  1. Connect your phone to your computer and find the drivers online (if needed) to allow adb to recognize your phone as a running Android device.  Eclipse and the ADT plugin will take care of the rest.
  2. The super dumb way is to take the .apk file that your Android project generates every time it compiles (at yourappfolder/bin/yourapp.apk), connect your phone to the computer via USB, push it to your phone, and install.  But that is also very inefficient (and dumb)!  What if you just wanted to test a small change real quick?  You would have to keep your phone tethered to the computer, and constantly overwrite your .apk file and re-install your application each time you wanted to test it on your phone.

I have a way that allows you to test your Android application on your Android smartphone without physically connecting your phone to your computer.  All it requires is a rooted Android smartphone, and a shared wifi network between the computer and the phone.

Note: This method requires a phone with root access, and accessing adb over a wifi network might be a security concern for some.  Take this method for what it’s worth.  If you are doing this on your own home network that is trusted and encrypted there shouldn’t be a problem, but I would avoid doing this in a public wifi network.

Video Walkthrough

What to do on your phone

Make sure you are connected to the same local network that your computer is on via WiFi.  You will then need an app called adbWireless, it allows a rooted phone to allow adb connection to your phone as if it was connected by USB.  Once you install adbWireless and allow root privileges, press the giant red button to begin.

It will provide you with a one-line command to run in your command prompt, something similar to “adb connect 192.168.1.106:5555″.  You can type “adb devices” afterwards to verify that your device is successfully connected.  That is all you have to do on the phone.

What to do on your computer

Go to Eclipse and click on the green play button so a drop-down list appears.  Press “Run Configurations”.

Next, press “Target”.  Change the radio button from “Automatic” to “Manual”.  Press “Apply” then “Run”.

An Android Device Chooser window should appear and your device should be listed as a running Android device.  Select it and press OK.

Your phone should begin downloading the app and launching it as soon as it completes.  You can verify in the Console window on Eclipse that adb is running and uploading/installing the .apk on your phone.

What about debugging?

It is pretty cool that you can wirelessly push your app to your phone to test.  However, what if you can run debug mode in Eclipse while you step through the app on your phone?  Well you can through this method, and it is faster than the emulator.  It is not that much different from the method described above.

Make sure in your AndroidManifest.xml that “android:debuggable=true” is there.  The easiest way to add this is to go to the “Application” tab in the manifest, and in “Application Attributes”, find “Debuggable”, set it to “true”, and then save.  By default, my phone denies the app from being run in debug mode if the application did not explicitly declare themselves as debuggable in their manifest.  So, make sure debuggable is set to true in your AndroidManifest!

Once you do that, just create breakpoints, and begin the debug mode.  Step through your app on your phone, and Eclipse will automatically switch to the Debug perspective when it hits a breakpoint.  This is seriously really cool.

Conclusion

I tried searching on Google to see if anyone else had written about this cool technique, but I wasn’t able to find anything so I decided to write my own how-to.  I was in the process of uninstalling apps that I don’t use anymore, and when I stumbled upon adbWireless which I downloaded but never used before, I thought about this possibility.  I tried it, and it worked.  This is, in my opinion, better than the other two methods mentioned above.  Laziness is good.

Tags: , , , , , ,

About

Jesse is a software engineer at Facebook, who just graduated from UC Berkeley. Passionate about mobile technology and entrepreneurship, he started his own blog as a home for his tutorials, projects, and random thoughts. Follow him on Facebook to stay updated on his latest tutorials and projects.

22 Comments »

  1. [...] Apps on the Device.1. The original procedure and how to connect to the device in Eclipse now is available here. Feel free to comment on his page and thank him if the procedure helped you! Enjoy!Thanks JesseChen [...]

    Pingback by How To: Connect to Your Android Device Through ADB Wirelessly | TheUnlockr — April 12, 2011 @ 12:31 PM

  2. Awsome!!! I have the same experience as yours until I search this one.

    Comment by Luke — May 10, 2011 @ 8:03 PM

  3. Wow really useful awasome

    Comment by Laxminarayana — January 6, 2012 @ 4:16 AM

  4. Thank you very much!
    BTW, if you get a timeout e.g. during upload, see this:
    http://stackoverflow.com/questions/4775603/android-error-failed-to-install-apk-on-device-timeout

    Regards,
    Anguel

    Comment by Anguel — January 8, 2012 @ 12:58 AM

  5. I enjoyed your rich writing. first class information. I hope you write others. I will carry on subscribing

    Comment by Vitamin B — April 1, 2012 @ 7:05 PM

  6. Can Android Webdriver be used through this process?

    Comment by Sourabh Roy — April 5, 2012 @ 10:10 PM

  7. Anchor3…

    [...]Debugging Your Android App Wirelessly on an Android Smartphone | Blog | Jesse Chen[...]…

    Trackback by Anchor3 — April 25, 2012 @ 8:41 AM

  8. dong phuc lop…

    [...]Debugging Your Android App Wirelessly on an Android Smartphone | Blog | Jesse Chen[...]…

    Trackback by dong phuc lop — May 20, 2012 @ 6:50 PM

  9. Awesome! But do you know anyway of achieving the same thing by not having to root the device?

    Comment by Vrashabh — July 31, 2012 @ 9:53 PM

  10. Works great on my rooted Nook Simple Touch! Thanks for the tip…I was just about to start bothering a lot of people in forums for this answer – you saved me a lot of trouble.

    …Tom

    Comment by TomK — September 27, 2012 @ 5:13 PM

  11. Nice tutorial, but I prefer using the cable, over wifi it just takes to long to upload & launch.
    By the way, I had to change the ADB connection time out to 60000ms for it to work.

    Comment by Dylan — December 7, 2012 @ 5:53 AM

  12. this is awesome! i seldom leave comments. this post really opens my eyes.
    thanks.

    Comment by passerby — December 18, 2012 @ 6:56 PM

  13. Hey there, You have performed an excellent job. I will definitely digg it and individually suggest to my friends. I’m sure they will be benefited from this site.

    Comment by app maker app — January 6, 2013 @ 1:27 PM

  14. Ur blog, “Debugging Your Android App Wirelessly
    on an Android Smartphone | Blog | Jesse Chen” ended up being definitely worth writing
    a comment down here in the comment section! Basically wanted to point out you really did a superb job.
    Thanks ,Elwood

    Comment by Anonymous — January 21, 2013 @ 2:41 AM

  15. Your personal blog, “Debugging Your Android App Wirelessly on an Android Smartphone | Blog | Jesse Chen” was indeed definitely worth commenting on!
    Just needed to say you truly did a great job.

    Thanks for your time -Patricia

    Comment by Anonymous — January 24, 2013 @ 3:41 AM

  16. Just submit. This web site is extremely intriguing, My partner and i additional the idea to be able to my top picks, I hope you can perform the identical together with my own.

    Comment by Matthew Regulus — February 7, 2013 @ 9:09 PM

  17. Remarkable things here. I am very happy to see your article. Thanks so much and I am having a look ahead to touch you. Will you kindly drop me a e-mail?

    Comment by Android Battery App — February 28, 2013 @ 10:12 AM

  18. Excellent blog you’ve got here.. It’s difficult to find quality
    writing like yours nowadays. I truly appreciate individuals like you!
    Take care!!

    Comment by led lighting strips kitchen — March 19, 2013 @ 10:35 AM

  19. Woah this blog is wonderful i like studying your articles. Stay up the great work! You realize, a lot of people are hunting around for this information, you can aid them greatly.

    Comment by green app machine review — March 26, 2013 @ 3:01 AM

  20. Thanks for finally writing about > Debugging Your Android App Wirelessly on an Android Smartphone
    | Blog | Jesse Chen < Liked it!

    Comment by download odin 3.09 — March 26, 2014 @ 8:21 PM

  21. I got this web site from my friend who shared with me regarding this website and at the moment this
    time I am browsing this website and reading very informative articles or
    reviews at this place.

    Comment by Dynasty Warlord apk — April 12, 2014 @ 7:08 PM

  22. Mobile development with new cycles are getting shorter, less than three months to buy a mobile phone, the new has come out, this benefit is developing too fast lenteen

    Comment by bryant — April 23, 2014 @ 11:20 PM

RSS feed for comments on this post. TrackBack URL

Leave a comment