Tuesday, October 26, 2010

Go Public with Your Android Application: Signing and Deployment (Part 3)

Generating Your Own Key
As mentioned, if you wish to publish your application to other users, you need to sign your application using your own personal certificate. You can generate your own certificate by using the keytool.exe tool (this also comes with your JDK). To generate your own certificate, issue the following command:

keytool –genkey –v –keystore learn2develop.keystore –alias learn2develop –keyalg RSA –validity 10000


The above command generates a certificate named learn2develop.keystore with the key alias learn2develop, generated using the RSA algorithm, and with a validity of 10,000 days (this is the minimum recommended). You will be prompted for some information (see Figure 7). In particular, you need to supply a password for the keystore and a password for the private key. If you are publishing your application for the Android Market, your keystore must have a validity period ending after 22 October 2033.Secure and protect these two passwords so that only people who are authorized to sign your applications know about them.


Once the learn2develop.keystore file is generated, you can now sign your application with it .
Deploying .apk Files
Once your Android application is signed, you can deploy them to emulators and devices using the adb.exe tool (located in the tools folder of the Android SDK).


For illustration, copy the MyKillerApp.apk created (and signed) in the previous section to the android-sdk-windows-1.0_r1\tools folder. To install the application to an emulator (assuming the emulator is currently up and running), issue the following command:




adb install MyKillerApp.apk
shows the successful installation of the application.To remove an installed application using the adb tool, you can use the shell option to remove an application from its installed folder, like this:

adb shell rm /data/app/net.learn2develop.MyKillerApp.apk
Another way of deploying an application is to use the DDMS tool in Eclipse . With an emulator (or device) selected, use the File Explorer in DDMS to go to the /data/app folder and use the "Push a file onto the device" button to copy the .apk file into the device.


Once this is done, the application will automatically appear on the device .
Easy and Essential
In this article, you've been walked through the process of signing your Android applications and how to generate your own keystore by using the jarsigner.exe and keytool.exe tools. Signing your application is absolutely essential if you want your application to run beyond the emulator. This is particularly true if you wish to publish your application on the Android Market.


Your Ad Here