Android Development 101 – Part 6:Getting Ready For Market!

In this tutorial we are going to cover packaging one of our applications into an .apk file and getting it ready for the Android Market.  After we have completed this tutorial you should be able to use the tools provided in the AndroidSDK to sign your application, put the application on your phone and install it or send it to the Android Market.  These will be great assets to have if you decide to develop applications that you may want to charge for.  This tutorial will also be a change from the normal ones because it will include little, if any, code.

To start off, if you have great aspirations for marketing your applications to others make sure to sign up for a developer account and pay the one time fee of $25 USD.  This will ensure that not just anyone is publishing to the market.  If your not looking to shell out the money then you can continue with the tutorial and give anyone who wants your app the file to put on their SD card. Whether you decide to do this step or not we still need to version our application.  We are going to use the EnhancedQuotes Project for this example.  We are going to open up the Android Manifest in enhanced quotes and put some code in here so we can version our application.

Versioning an application means that we make the application able to accept updates if something breaks or we are adding more features.  Once the Android Manifest is open we are going to modify the line where it says

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gregjacobs.enhancedquotes" >

and add in

<android:versionCode=”1” android:versionName=”1.0” >

so that the line should look like

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gregjacobs.enhancedquotes" android:versionCode=”1” android:versionName=”1.0”>

This tells the device we run the app on that this is version one and anything that comes along that is higher will be upgraded.  We need to add in a minSDKVersion as well so the Android Market can tell which devices can use our application.  We need to add

<uses-sdk android:minSdkVersion="3" />

underneath the /application node that will be shown below. We also want to add a specific icon so that our application stands out from all the other ones on a persons device.  I chose this icon and saved it to an easy to find place, naming it icon.png, then dragging onto the drawable folder in res/.  Eclipse will ask you if you would like to overwrite, just say yes.

We now need a private key that will allow us to sign applications by using this key in the signing process. It will have to be your, it will show its either for your work or personal development depending on how its created and have a period of time before it expires.  To make a private key we are going to use the keytool found in our C:/Program Files/Java/jre6 folder.  Once inside the jre6 folder, hold shift and right click on the bin folder and choose the option that says Open command window here.  Once in the command promp we are going to run keytool with a bunch of commands that will assist us in making a private key. The command to be entered into the command window will be as follows:

keytool -genkey -v -keystore C:/MyKeygen.keystore -alias MyKey -keyalg RSA -keysize 2048 -validity 10000.

Now that we have the command entered we can step through and determine what each of these variables is doing for the keytool.

  • -genkey – Initiates the start of the making a key pair.
  • -v – Enables output to be shown to the user making the keystore.
  • -keystore – After this variable will contain the location and the name of the keystore we are going to make.
  • -alias – Gives the keystore a shorter name or nickname if you will.
  • -keyalg – This is the type of encryption used and can be either RSA or DSA encoded.
  • -keysize – The size of each key that is generated.  This is recommended to be at least 2048 bits or higher as stated by Google.  The default is 1024 bits.
  • -validity – The number of days the key is valid.  This should be no less than 10000 but is recommended to go higher.
After pressing enter when done entering the command above you will be prompted to answer a series of questions so Google can validate this key.  The first question will be a password for the key and it will prompt you to re-enter it as well.  The password will not show up when pressing keys but it is working and it is key to remember this password because we will use this when packaging our app.  Next question will ask for your first and last name.  The thirst question asks for the unit you are in, I put development since we are programming for android.  Next is your organization, remembering if you aren’t programming for one just enter your name or whatever you wish.  Next is just the city you are located in.  Then state or province depending on your locale.  Enter the two digit country code that you are in, for example Canada would be CA and United States of America would be US.  It will then prompt us if this information is correct, if it is type n yes then press enter.  It will now prompt you for a password for mykey, press enter as we will use the same key as the keystore password.

We are now ready to sign the application and get it ready for deployment to the Android Market.  We do this by going to eclipse and in the Package Explorer right click on EnhancedQuotes, go to Android Tools then click Export Signed Application Package….  This will open up a dialog box asking you the project you want to export, click next as the one we want is selected.  Now we want to click the browse button on this page and locate our keystore file we created earlier, make sure to enter the password for it and click next.  Choose the alias we created for it and enter the same password as before and click next.  Now choose the destination for the APK file we are about to create, I am choosing the C Drive. Click Finish and the APK file will be created in the directory we chose.


We now have two choices for publishing our app, the first being deploy on your android device by dropping it on the SD card and downloading an app installer like appInstaller from the marketplace or deploy to the android community via the Developer Publish site.  We are going to publish to market in this tutorial.  Navigate to the publisher site, log in and then click on the button that says Upload Application.  We now need to find the APK file via the first browse button then enter some information about the application.  After filling out the Title, Description, Application type and category, choosing your publishing options and filling out contact information and finally agree to the terms by checking the checkboxes we can finally press Publish.  After pressing Publish the application is sent to the market and you can have millions of Android users use your application.  In the demo of this application the app I signed was actually sent to market and can be found by clicking search in the Market and entering in Quotes Viewer/Generator.  The link provided will only work on an android device, or you could scan the QR code below if you wanted to get there faster.

APK File

This series of tutorials has covered the basics of development in an Android Environment to packaging up your applications and getting them ready for market.  Now that we have the basics of Android development down we can start on tutorials about more advanced subjects including but not limited to bluetooth control/chat.  I hope everyone that has read Android Development 101 has found it useful and looks forward to more. Happy Hacking until the next tutorial!

25 thoughts on “Android Development 101 – Part 6:Getting Ready For Market!

  1. I have a basic question: once an app is in the Android Market, is there a URL that points to that app? It seems the only way to access an app is through an Android device itself. Great unless you want to link to it from your own site. I’d settle for the QR barcode equivalent.

    Odd ya can’t search the search leader’s own marketplace…

  2. I love that you guys have finally got this whole “Article that isn’t a hack” thing down. There were some rocky bits with that top 10 stuff. This is an awesome howto series. Thanks Hackaday!

  3. Dont forget. put your app’s apk on your website and not only in the market. making people have to search for your app on torrent sites because you wanted to be a douchebag and only put it in the market tells non blessed android users that you hate them.

    as a android tablet owner, I am forced to torrent all my apps because of lazy developers not putting their apps online anywhere but the market.

  4. @fartface

    What if your app isn’t free? There are alternative market places but if you want to get any sort of distribution you would be insane not to upload to the official market place.

    You should have a go at getting the vending.apk and see if you can get the official market place running on your device.. but IIRC the only devices that ship without it are ones produced by vendors that haven’t accepted googles policies (i.e. all devices need to allow ADB etc).. do you have one of the tablets from deal extreme by any chance?

  5. The PDF option would be great. But, could you also go back to tutorials 3-5 and add a link to the next one? For those of us who are doing them in a row, and don’t want to have to search for the next one.

  6. Just a heads up for other users out there. On Windows 7 (and maybe Vista) you will need to enter the CLI as Administrator in order to get the keygen to work. CTRL+SHIFT+ENTER when opening cmd.exe from a Run box will do the trick. This will allow the MyKeygen.keystore file to be created if it doesn’t exist already.

  7. @Greg: how about some /reverse/ links that point to the previous part and/or the first part, so we can start from the beginning without digging through the “Android hacks” category?

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.