Packaging Our Application for Release

Packaging Our Application for Release

We finally made it. Our coding is done, we have an application icon, and it’s time to package the application for deployment. This involves a number of steps:

1. Building our application in release mode, and then signing our application for deployment.

2. Registering for the Android Market.

CHAPTER 12: Polishing and Packaging an App for Release

3. Publishing our application to the market. In this final section of this chapter, we will cover what is required to complete step 1

successfully, and then we will point you in the right direction so you can complete steps

2 and 3 with your own application once you reach that point. While there are some nuances to building the application for release (most of which are now handled during the build process), the registration and application-publishing processes are made very simple by Google. Additionally, they provide an excellent guide on the topic of publishing your application (see http://developer.android.com/guide/publishing/publishing.html).

The first step in building our application for release is using ant to build a binary of the application in release mode. This is achieved by running the following command from the Moundz PhoneGap project directory: ant release.

When run, this command should generate output similar to that shown in Figure 12–18.

Figure 12–18. Output from running the build in release mode—note the comments regarding signing. In this figure, you may notice some output generated by the Ant build referring to not

having key.store or key.alias properties available with which to sign our application. This has prevented the build script from successfully signing our application, which is required if we wish to distribute our application.

CHAPTER 12: Polishing and Packaging an App for Release

To sign our application, the first thing we must do is generate a private key. This can be achieved by running the following command (however, you should change both the keystore and alias to something more appropriate for your own configuration):

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA - keysize 2048 -validity 10000

Running this command shows output similar to that displayed in Figure 12–19.

Figure 12–19. If you don’t already have one, you will need to generate a private key to sign your application. With our keystore created, we can now modify our build.properties file and specify its

location so the build script can sign our application as part of the build process. With our application requirements, there are no additional settings required in this file, so, after the key.store and key.alias properties are added, our build.properties file should look something like the following:

key.store=/path/to/release-key.keystore key.alias=your_alias

Now, with those settings in place, we are ready to attempt rebuilding our application in release mode. If everything has gone correctly, you should now be prompted for your keystore and alias password as part of the build process. Provide the password correctly, and your application will be signed and ready for release. Figure 12–20 shows an example of the output that will be generated in a successful build.

CHAPTER 12: Polishing and Packaging an App for Release

Figure 12–20. After generating a private key and providing details to the build script, our build process successfully signs our application.

If you have a look in the bin folder of your Moundz PhoneGap project folder, you should see a number of files. The most important one as far as a project release is concerned is moundz-release.apk. Figure 12–21 shows an example screenshot of what your bin folder might look like.

CHAPTER 12: Polishing and Packaging an App for Release

Figure 12–21. The bin folder of the Moundz PhoneGap project folder should contain a moundz-release.apk file after our successful build.

That’s it. We now have the main application file, which will enable us to publish an application to the Android Market.

If you decide to go down this path with your own Android web apps, then from this point you should register with the Android Market ( http://market.android.com/publish) and, as mentioned previously, familiarize yourself with Google’s publishing guide that we referenced early in this section of the chapter.

In terms of the tasks that remain, you will need to gather a few screenshots, make some larger icons, and think of some text that describes your application well to potential users. If you are looking to sell applications through the market, then you should also investigate a Google Merchant account.

From here on, you enter the land of pictures, text, and promotion.

CHAPTER 12: Polishing and Packaging an App for Release