Daily Archives: January 15, 2011

Solution for Android Emulator Starts But App Doesn’t Run

I recently got started with Android app development.  My motivation for this, is that I decided to add tabata to my training regime.  This is something I’ve wanted to do for ages, but has only recently become possible (yay for January sales and cheap heavy bag stands!).  There are a few tabata apps out there, but none are quite what I want, so I decided to make my own.

I downloaded and installed Eclipse, since that’s the IDE used in the Android developer tutorials, and installed the Android SDK, then tried the Hello World tutorial.  When I ran it, the emulator started up, but the app didn’t run.

It turns out that this is a common problem, and there could be any number of causes.  I’m posting the solution that worked for me here, because it turns out I had two issues, and it’s likely that people following the tutorials may end up in a similar situation themselves.

The first issue I found was that I’d missed a step out of the Eclipse configuration process.  Under Run -> Run Configuration, I hadn’t set the Launch Action for Android applications.  I found that Launch Default Activity didn’t work reliably for me, so I’ve selected my application under Launch: which seems to work better.

Secondly, I’ve found that adb.exe has a tendency to hang.  The workaround for this is to attempt to run the application, and then give the emulator time to start up.  If your app doesn’t launch, use Task Manager to end task adb.exe (or kill the adb process if you’re using Linux).    Leave the emulator running, and re-run your application in Eclipse.

This technique seems to be working reliably for me.  Sometimes adb hangs again (and end tasking it solves that problem).  It would be nice if I could figure out why this is happening, but for now it works well enough, and my app is making good progress!