While you may or may not encounter this exact error, depending on what release of the Android SDK is available when this book is published, you should follow the troubleshooting steps presented here, because they will help you in later projects.

This error seems to point to the fact that my classes, somehow, are missing from the HelloWorldCommandLine.apk file. I can easily remedy this issue without using any of the Android SDK command-line tools.

As it turns out, .apk files are just .zip files. That is, you can easily open them with a .zip file decompressor and view the files within them. The following illustration shows what the inside of HelloWorldCommandLine.apk looks like using the WinRAR decompressor.

HelloWorldCommandLine.apk - Win RAR (Evaluation copy) Fite Commands Tools favorites Options Help

Add Extract To Test View Delete

Find Wiidrd info

Comment SFX


HelloWoridCommandLine.apk - ZIP archive, unpacked size 2.752 bvtes

I Name


Packed Type


CRC 32


,'-.v. Android M ariiftstxml 1.50S Q resources.arîc Ë LJ 2

holder 1,508 XML Document

692 File arse

¡¡/1V21HJÜ B:23 ... 3/1S/200S 8:23... 0AT55E0S ifWiOOS a-13 CDÏ314E4.

What is missing from the file is classes.dex. This is the compiled Dalvik executable of my classes. Navigating to the bin directory of my Android project, I can see that ANT did successfully compile and create the classes.dex file. The file was just left out of the HelloWorldCommandLine.apk. With the .apk file open in WinRAR, I can drag-and-drop classes.dex into HelloWorldCommandLine.apk. After classes.dex has been added to my .apk file, I can save and close the file.

Uninstalling a Prior Version of an Activity

Before you add the file to your running Android server, you are going to uninstall the prior version of HelloWorldCommandLine. Uninstalling a prior version of an application before you install another is not required. However, to get a good look at how to interact with the Android server, go ahead and uninstall your previous version before proceeding.

With your Android Emulator open, return to your command prompt environment and run the command adb shell, which opens the shell environment of the Android server. If you are successful, your command prompt should turn from a > to a #.

You now have an open shell into your Android server. There are a multitude of functions you can run from this point, but for now focus on one: removing the old HelloWorldCommandLine.apk file.

0 0

Post a comment