Blog | jessechen.net

Debugging Your Android App Wirelessly on an Android Smartphone

March 16, 2011 8:20 pm by

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.

Filed under: Android,How to — Tags: , , , , , , — Jesse Chen @ 8:20 PM

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.


How Google Voice Saved My Interview

February 9, 2011 11:55 am by

Last Friday, I was scheduled for a phone interview with a small startup called Arrayent (they are doing some pretty exciting stuff though, check it out).  A series of unfortunate events that almost led me to miss my phone interview.

This is a story of how Google Voice saved my interview.

EDIT: This article got featured on Lifehacker!

Google Voice can be boiled down into one sentence: One number for people to reach you.  Keep this idea in mind for later.

With Voice, gone goes the need to spam all 648 of your friends on Facebook with a public event (“HAYY GUYS I HAVE A NEW NUMBER!”) to tell everyone your new number and ask for their phone numbers such that anybody on Facebook can see who was dumb enough to post their phone number on a public, searchable event (/rant).

So how exactly did Google Voice save my interview?

First, if you do not fully understand what Google Voice does, scroll down and quickly read what Google Voice is – that way, what I am about to say will make more sense.

I had a phone interview scheduled for 2pm with a small startup called Arrayent.  Problem was, the day before, I issued a request to port my old ATT number to my phone.  The reason for this was because I do not know my actual Verizon phone number (I have been exclusively using Google Voice), and I wanted to keep my old phone number (that I actually do remember).  In any case, the Verizon rep said the process would take 1-2 days.  The consequence of this procedure was that my phone would not be able to connect to Verizon’s network.  I was not completely notified of that, and as such, I began to worry as the time for my interview was coming up and my phone was still not able to send/receive calls.

I thought, well, since I gave my Google Voice number to the interviewer, I can just pick up the call on my desktop through GMail right?  Sounds like a great plan, except when I came home at about 1pm, Comcast decided to just fail (seriously..again?) and there goes my genius solution.  Comcast was actually down just a few hours before the Super Bowl last Sunday, nearly two days.  Sigh.  Both Verizon and Comcast were not working for me, and my interview was scheduled to start in about 15 minutes.

As things started looking grim, I remembered my friend had an Android smartphone.  I was able to sign into Voice through his phone, temporarily adding his phone number as one of mine on Google Voice.  Such that when my interviewer called promptly at 2, I picked up his call to my number through my friend’s phone.  I explained my situation to the interviewer and he chuckled at my situation.  In the end, everything went smoothly (I think) and well, we’ll see what goes from there. 🙂

Had it not been for Google Voice and its ability to dynamically add and remove phones to your Google Voice number, things might have turned out differently, for the worse!

Note: My other idea was to actually wireless tether my laptop to my friend’s smartphone and receive the call through my laptop because Google Voice had a pop up warning that it was going to delete all data from my friend’s Voice account when I was trying to sign out of his account.  I tested the call quality on the laptop tethered to the phone with a friend but he said the voice quality was really bad (However, I used this setup after the interview to call somebody and he said it was fine!).  Turns out signing out of Google Voice on your Android smartphone seems to only lose your settings for the Google Voice app.  All the texts and call logs are still synced with the cloud.

For those who do not know what Google Voice is:

I like to explain that Google Voice is like a “router”.  It serves as the hub that all your telephone devices can connect to.  All incoming and outgoing calls are made through the “router” so that even if your actual phone’s number changes, you don’t need to worry about telling everybody what your new number is.  What are the other cool features of Voice?

  • Free, unlimited texts – I use a Google Voice number exclusively, and don’t have to pay for a texting plan at all!
  • Free calls through 2011 – Google was generous enough to continue offering free calls through 2011 when you call through GMail.
  • Synced to the “cloud” – I can’t stress how awesome this is.  When I am in a place with no reception (basement of Soda Hall), I can go to Google Voice’s website and still text my friends.  When I am on my computer, I can quickly reply to a text through the Google Voice Chrome extension, rather than unlocking my phone, and pecking (or “swyping”) on the tiny screen.  I can go on any computer with an Internet connection to text and make calls (as long as the computer has a microphone) through my phone number.
  • One number rings multiple phones – When I am on my computer, I can pick up my call through my GMail, or my phone.  Sometimes it is more convenient to just pick up the call through the computer, or maybe a land line (if those still exist!).
  • Voicemail transcription – If you are unable to pick up your phone and the caller leaves a voicemail, Voice will attempt to transcribe the voicemail.  Although it is not perfect by any means, usually it gets enough words correct to get the gist of the voicemail.

These are the best features of Voice, and the cool thing about all this is it’s free.  However, the biggest roadblock for people who want to convert is – well, I don’t want to change the number I have now!  I want to use Google Voice but I don’t want to change my number. Fortunately, that was one of the most requested feature, and as of a few weeks ago, it has been implemented.  You can now port your number to Google Voice but beware of the possibly early termination fees that your carrier might charge.

Google Voice is a great product, but in order for it to gain traction, it needs to guarantee uptime.  Last November, Google Voice was having major downtimes and made people realize that if they completely rely on it, when Google Voice goes down, their ability to send and receive calls would also go down.  If Google wants more people to jump aboard (and businesses alike), it is in their best interests to have a guaranteed uptime, make it scalable, and eventually have a fully-staffed customer support.  As of now, it is a free phone service and as the saying goes, “you get what you pay for”.

EDIT: the Lifehacker effect!

Holy crap! Almost 6,500 views on my article!
Filed under: Android — Tags: , , , , , — Jesse Chen @ 11:55 AM

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.


How to Maximize Your Android’s Battery Life and Phone Responsiveness

December 29, 2010 2:41 am by

Introduction

I have explored many forum posts and the various attempts that people do to extend the battery life on their Android smart phone.  The battery life is an issue, for most people, their stock smart phone can barely last a day before it is out of juice.  Android is, in my opinion, is superior to iOS but the hardware that is packaged with the Android OS (and maybe a bit of the power management code in Android) is a huge flaw in an otherwise perfect smart phone.  The iPhone’s battery life is better than the typical Android smartphone, and that is something I am here to fix.

When I first got my Droid X, it came with the standard 1300mAh battery and it would usually last only about 6 hours after a full charge.  That is extremely low but that is because I would turn it on and play with it every few minutes since this was a new sexy smart phone.  Under normal circumstances, where an average person would probably be working from 9-5, thus, using the phone only to occasionally check email and calls, my battery life then would be about 8 hours.  That is still really sad because I was accustomed to my dumb phone that can usually last 2 full days without needing another charge.  Looking around the various forums like xda-developers, mydroidworld, and others, battery life is clearly an issue with Android.  I have been using my Droid X for almost half a year now, and I am confident to say that I have gathered the best set of tips that will maximize your battery life and make your phone faster and more smooth.

This is what to do

Step 1: First things first, make sure you set your brightness as low as you can tolerate, I use auto brightness which works for me.  The display uses up the most battery life so lowering brightness as much as you can will play a significant role in increasing your battery life.  Set your screen timeout to as low as possible as well.  Keep in mind to turn off wifi and bluetooth when you can.  Those radios use a good amount of energy.  GPS you can leave enabled because unless an app is using the GPS radio, it will otherwise be off.  However, do keep in mind that the fastest way to drain your battery is probably by using the GPS.  You can configure all these in Menu > Settings > {Display | Wireless & networks}.  When you want to close an app, keep pressing “back” to fully exit an app – pressing “home” generally will save the state of the app in memory so you can go back to the way it was later.

Step 2: Root your phone.  Technically, it breaks your warranty but it has been known that nobody really checks nor cares if you send it back in for repair.  Plus, rooting your phone gives you admin privileges – which allows you to do a lot more with your phone (wireless tethering, skinning/theming, use root-required apps).  z4root supports many phones and roots the phone for you, it’s so simple anybody can do it.  Check to see if your phone is supported, otherwise, use Google to search how to root your phone.

Step 3: Now that you have root, it always helps to remove bloatware that the carriers have put on the phone.  For the Droid X, there is a list of apps that people have confirmed is safe to remove from your handset.  However, when there is a software update, it will most likely check to see if all the apps are installed, so usually you want to just rename the *.apk file to *.bak, such that it will remove the app, but later you can easily change all the *.bak back to *.apk when update time is due.  I don’t recommend doing this because I did this prior to an update, but I was not smart and actually deleted the apks off my phone, so I had to figure out which apps I didn’t have and reinstall them on my phone before updating.  I do not recommend this step, although some people might want to.

Step 4: Do you ever feel like the default home launcher (main screen on your phone) is slow and sluggish?  Install LauncherPro, it is the best home launcher out there.  It has so many customizable tweaks and is extremeley smooth and fast.  Make sure to: enable the setting that keeps LauncherPro in memory, minimize the amount of screens and widgets, use homescreen caches, prevent force-close, and twiddle with the memory usage presets.

Step 5: Autokiller is a free app that allows you to tweak the memory settings on your phone.  In a nutshell, this app basically allows you to control how much memory can be used up before it starts freeing memory from apps.  Remember that memory unused is memory of no use, so freeing too much memory is not necessarily a good thing.  Android is designed to gobble memory because it allows apps to boot up faster and be more responsive.  However, sometimes having too many apps open and residing in memory slows the phone a bit.  With Autokiller, press Menu > Presets and choose one.  I use aggressive and it seems to work for me, those numbers mean the amount of memory each app category can use up before it starts killing apps.  Play around and choose one that fits you best.  It has been said 60MB remaining is when the phone begins to slow down.

Step 6: One of the benefits of rooting your phone is having the ability to run apps that require root privileges.  Autostarts is a 0.99$ app that allows you to see “what apps run on phone startup, and what other events trigger in the background. Root users can disable unwanted autostarts and speed up their phone boot”.  Download this app, and give it a few seconds to populate the fields.  Think of msconfig and how you used it to disable crapware that forced itself to startup on boot.  Once it is done loading, you will want to go through the list and disable any unwanted apps, check out especially in the “After Startup” section.  Use common sense and go through the list disabling apps such as CityID, Blockbuster, and that Nascar game.  Please make sure not to disable a crucial system process.

Task Killers

There has been endless debates about whether to use a Task Killer to kill tasks.  From what I get, before Android 2.2 – using a Task Killer to occasionally kill apps that weren’t in use was somewhat beneficial and good.  However, with the 2.2 update there is no longer a need for that.  This article provides a very deep technical insight as to why you should not use Task Killers anymore.  I use Android System Info to monitor and sometime kill a rogue task that is slowing down the phone.

Conclusion

I hope those tips help increase your battery life.  With my 1840mAh extended battery and those tips, my phone can last 2 days easily if I rarely use it (only for calls and checking email).  Otherwise, during a normal school day I would be using the phone on the bus to school, and browsing the web during class (oops), while eating, and time in between classes – quite a heavy user here.  I would take my phone off the charger at around 10am, and after school and work, my battery life would be about 60% around 7pm.  It has improved significantly and even though I have 141 apps installed on my phone, it is still as fast and smooth as the way it was when I first got the phone.

Filed under: Android,How to — Tags: , , , , , , — Jesse Chen @ 2:41 AM

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.