Riches and Glory
Launching a mobile application could be considered the latest get-rich-quick scheme.
And I suppose for some it might be their best chance at riches and fame.
Reality indicates that most developers don’t make back their investment by publishing an application to the App Store or Android Market.
In fact, when you view some of the comments posted for a particular application it can be a bit depressing. For example, I have seen many comments similar to this:
“Not a bad application… but I was expecting more for three dollars”
As someone who has made a living writing software that costs more than $3 I have to confess that I find that sort of comment at once ludicrous, laughable and even intimidating.
Coming up with a good application idea that will make you a million simoleons is a topic for another day, and unfortunately probably written by another author!
This article is the first in a two part series where we look at publishing an application to the Android Market.
In order to publish an application to the market, you need to have an account with Google and you need to digitally “sign” your application.
Registering as a developer with Google is a relatively painless process — in fact, it is a walk in the park compared to Apple’s process. Registering with Google is an exercise left to the reader. To get started visit http://market.android.com and click on the link at the bottom to learn more about publishing your application. At last glance, there is a $25 registration fee to publish applications. However, if you don’t have an application ready to publish just yet, you can hold off on this step for now and hold on to your 25 greenbacks until you are ready.

Register with Google
Regarding the signing of applications — the first question to answer is “why”?
Applications are signed with unique developer keys in order to limit the chances of a rogue application finding its way into the market to be downloaded by the unsuspecting and uninitiated. I say “limit” and not eliminate because the Android Market is really a bit of a free-for-all. The bar for becoming a registered developer is so low, that the accounts are almost disposable — particularly when contrasted with the process required by the Apple App Store.
This article is assumes you have an application already written and ready for publication. The term “ready for publication” is arguably somewhat subjective, but for our purposes here we assume your application is ready for prime time.
Let’s get started and learn how to sign an Android application in preparation for submission to the Android Market.
Signing your application
All applications which run on the Android platform must be signed. When you build an application in Eclipse and run it on either a simulator or a connected device it has silently been signed with a “debug” key. An application file, known as an Android Package File (*apk), signed in this manner is not accepted in the market. Your app must be signed with a different key, known generically as a “release” key.
The easiest way to generate a release key is to use the keytool utility which ships with the JDK. The command that follows may be run from the command line to generate a key named “releasekey”.
keytool -genkey -v -keystore ~/mykey.keystore -alias releasekey -keyalg RSA -validity 10000
This command generates a key:
- named releasekey
- with the RSA algorithm
- which is valid for 10000 days
- and is stored in the mykey.keystore file within the home directory of the signed-on user.
You will be prompted for a password which is used to secure access to the key. Please remember this password!
The keytool utility has an enormous list of options. For fun, type keytool and hit enter to see the usage options.
The next step is to build the application in an “unsigned” package. Remember, when you just “build” an application in Eclipse with the Android Developer Tools (ADT), you get a debug-signed application file (*.apk). To get an unsigned application package, highlight your project and then select the Export Unsigned Application Package menu from the Android Tools menu, as shown below.

Export application from Eclipse
Once the application has been exported it must be signed with the release key. To do this use the jarsigner utility as shown here:
jarsigner -verbose -keystore ~/mykey.keystore <path to apk file> releasekey
Enter Passphrase for keystore: ****************
updating: META-INF/RELEASEK.SF
updating: META-INF/RELEASEK.RSA
signing: res/layout/main.xml
signing: AndroidManifest.xml
signing: resources.arsc
signing: res/drawable/icon.png
signing: classes.dex
You will again be prompted for your password. At this point the application is signed, but we’ve got one more (optional) step to go before it is ready for uploading to the market.
The apk file contains a number of resources which are loaded at run-time. If the resources are properly aligned within the file then Android can “memory map” the application at run-time, alleviating the burden of loading the file’s contents into memory. This is a desirable feature, so let’s look at how we can “align” the file.
To perform this alignment we utilize the zipalign utility which is found in the tools directory of the Android SDK.
zipalign -v 4 inputfile.apk outputfile.apk
Prior to submitting the application to the Market, it is a good idea to test it on a local, physical device.
To install this file directly to an attached Android device use the adb utility:
adb install outputfile.apk
To uninstall an application using the adb utility you need to reference the application’s package rather than the apk filename:
adb uninstall com.msi.linuxmagazine.somecoolapp
Next steps
At this point the apk file is ready for submission to the Android Market. If you have questions on signing your application, please post them as comments to this article.
In the next article we look at uploading of the application to the Market and filling out the various data related to publishing an application to the Market.