When Android doesn’t Launch your application

As I've been getting started with Android I decided to take some notes. What follows is something I wrote down as I was working on getting a first sample to build and download from Eclipse using ADT. I followed the instructions from Google and tried the troubleshooting directions. My platform is OpenSuse 10.3 Linux. This note might be helpful if you're trying to develop for Android.

I had some trouble with getting a few of the sample apps to show up in my emulator. What I ended up doing was manually sending them to the emulator. To do this I used adb from the command line. When you run adb on the command line it is supposed to start up the server if needed but that wasn't my experience. I think what happened was that somehow the Eclipse ADT plugin runs adb after building to send the apk file to the emulator but since adb didn't always start the server the application didn't end up being sent. For example, in the Eclipse console I could see this output

[2007-11-16 10:39:06 - LunarLander] Android Launch!
[2007-11-16 10:39:06 - LunarLander] Launching: com.google.android.lunarlander.LunarLander
[2007-11-16 10:39:06 - LunarLander] Launching the emulator.

And nothing following it. In this case the emulator would eventually start but it didn't launch the intended application at startup - it hadn't actually downloaded the latest code built (which is what the apk file contains). Trying to run adb from the command line then gives a result like this
rob4@copper:~/android_sdk/samples/SkeletonApp/bin> adb install SkeletonActivity.apk
* daemon still not running *
error: closed

When it works from the command line it looks more like this

rob4@copper:~/android_sdk/samples/NotePad/bin> adb install NotesList.apk
486 KB/s (46279 bytes in 0.092s)

After investigating some more I've discovered that things work right if you manually kill the adb server after quitting the emulator. To be clear, the workflow is basically this:

  1. Edit code
  2. Build
  3. Run - emulator starts up
  4. Quit emulator (by just closing the window it runs in)
  5. Kill the server with the command adb kill-server
  6. Repeat

Then you don't need to do the manual download for the apk file. The output in the Eclipse console should look something like this

[2007-11-16 10:49:57 - HelloAndroid] ------------------------------
[2007-11-16 10:49:57 - HelloAndroid] Android Launch!
[2007-11-16 10:49:57 - HelloAndroid] Launching: com.latenightpc.android.hello.HelloAndroid
[2007-11-16 10:49:57 - HelloAndroid] Launching the emulator.
[2007-11-16 10:50:07 - HelloAndroid] Emulator is up! Waiting for HOME to be launched.
[2007-11-16 10:50:08 - HelloAndroid] HOME is up!
[2007-11-16 10:50:08 - HelloAndroid] Pushing HelloAndroid.apk to /data/app on the device
[2007-11-16 10:50:08 - HelloAndroid] Starting activity on device: com.latenightpc.android.hello.HelloAndroid
[2007-11-16 10:50:11 - HelloAndroid] ActivityManager: Starting: Intent { comp={com.latenightpc.android.hello/com.latenightpc.android.hello.HelloAndroid} }

At this point the emulator fires up and is running the expected application with the latest changes in it. For more information on adb and how to use it just run adb --help or go to the Google page about it.

Your rating: None Average: 4 (1 vote)

here's my petition against android: say no to a google dominated web.

Also, you can this from within eclipse by switching to DDMS view and selecting "Reset ADB" from the triagly dropdown menu.

I think I've found the button you're talking about and I want to go in to more detail (and more screenshots) on the debug view in a later post. The debug view has some really cool features and it's a lot better way to debug than just changing code & running again (as a debugger should be).

Thank\'s very much for that info - I\'m also using suse10.3 and I had exactly the same problem and already lost 2 or 3 hours with it - tried to reinstall everything with deleting ~/.eclipse and ~/.android directories. The worst thing is that initially it works and installs the app to the emulator, and then it just stops doing that. Could lose much more time without your article.

Thanks mate, had exactly the same problem on Windows (Vista). Now sorted.

Glad it helped. I've just run in to it again now. For the most part what I'm doing these days is leaving the emulator up then just picking my debug target from the menu. I can see the console output that says it downloads then (usually).

Tnx, it has solved my issue

Thanks dear it has solved my problem.....it was facing this issue form pas two days and i am not able to solve this, thanks once again...

You saved me from a lot of frustration - thanks!

Thanks you very much for this help.

can you please explain how to get to this "DDMS view"

To get to DDMS click Window -> Open Perspective -> Other... then it should show up in the list of Perspectives. DDMS is actually a perspective which means it has a set of views.