Packaging Your Application for Publication Android

There are several steps developers must take when preparing an Android application for publication and distribution. Your application must also meet several important requirements imposed by the marketplaces. The following steps are required for publishing an application:

  1. Prepare and perform a release candidate build of the application.
  2. Verify that all requirements for marketplace are met, such as configuring the Android manifest file properly. For example, make sure the application name and version information is correct and the debuggable attribute is set to false.
  3. Package and digitally sign the application.
  4. Test the packaged application release thoroughly.
  5. Publish the application.

The preceding steps are required but not sufficient to guarantee a successful deployment. Developers should also

  1. Thoroughly test the application on all target handsets.
  2. Turn off debugging, including Log statements and any other logging.
  3. Verify permissions, making sure to add ones for services used and remove any that aren’t used, regardless of whether they are enforced by the handsets.
  4. Test the final, signed version with all debugging and logging turned off.

Now, let’s explore each of these steps in more detail, in the order they might be performed.

Preparing Your Code to Package

An application that has undergone a thorough testing cycle might need changes made to it before it is ready for a production release. These changes convert it from a debuggable, preproduction application into a release-ready application.

Setting the Application Name and Icon

An Android application has default settings for the icon and label. The icon appears in the application Launcher and can appear in various other locations, including marketplaces. As such, an application is required to have an icon. You should supply alternate icon drawable resources for various screen resolutions. The label, or application name, is also displayed in similar locations and defaults to the package name. You should choose a user-friendly name.

Versioning the Application

Next, proper versioning is required, especially if updates could occur in the future. The version name is up to the developer. The version code, though, is used internally by the Android system to determine if an application is an update. You should increment the version code for each new update of an application. The exact value doesn’t matter, but it must be greater than the previous version code. Versioning within the Android manifest file is discussed in Chapter “Defining Your Application Using the Android Manifest File.”

Verifying the Target Platforms

Make sure your application sets the <uses-sdk> tag in the Android manifest file correctly. This tag is used to specify the minimum and target platform versions that the application can run on. This is perhaps the most important setting after the application name and version information.

Configuring the Android Manifest for Market Filtering

If you plan to publish through the Android Market, you should read up on how this distribution system uses certain tags within the Android manifest file to filter applications available to users. Many of these tags, such as <supports-screens>, <uses-configuration>, <uses-feature>, <uses-library>, <uses-permission>, and <uses-sdk>, were discussed in Chapter “Defining Your Application Using the Android Manifest File” Set each of these settings carefully, as you don’t want to accidentally put too many restrictions on your application. Make sure you test your application thoroughly after configuring these Android manifest file settings. For more information on how Android Market filters work, see market-filters.html.

Preparing Your Application Package for the Android Market

The Android Market has strict requirements on application packages. When you upload your application to the Android Market website, the package is verified and any problems are communicated to you. Most often, problems occur when you have not properly configured your Android manifest file.

The Android Market uses the android:versionName attribute of the <manifest> tag within the Android manifest file to display version information to users. It also uses the android:versionCode attribute internally to handle application upgrades. The android:icon and android:label attributes must also be present because both are used by the Android Market to display the application name to the user with a visual icon.

Disabling Debugging and Logging

Next, you should turn off debugging and logging. Disabling debugging involves removing the android: debuggable attribute from the <application> tag of the AndroidManifest.xml file or setting it to false. You can turn off the logging code within Java in a variety of different ways, from just commenting it out to using a build system that can do this automatically.

Verifying Application Permissions

Finally, the permissions used by the application should be reviewed. Include all permissions that the application requires, and remove any that are not used. Users appreciate this.

Packing and Signing Your Application

Now that the application is ready for publication, the file package—the .apk file—needs to be prepared for release. The package manager of an Android device will not install a package that has not been digitally signed. Throughout the development process, the Android tools have accomplished this through signing with a debug key. The debug key cannot be used for publishing an application to the wider world. Instead, you need to use a true key to digitally sign the application.You can use the private key to digitally sign the release package files of your Android application, as well as any upgrades. This ensures that the application (as a complete entity) is coming from you, the developer, and not some other source (imposters!).

The Android Market requires that your application’s digital signature validity period end after October 22, 2033.This date might seem like a long way off and, for mobile, it certainly is. However, because an application must use the same key for upgrading and applications that want to work closely together with special privilege and trust relationships must also be signed with the same key, the key could be chained forward through many applications. Thus, Google is mandating that the key be valid for the foreseeable future so application updates and upgrades are performed smoothly for users.

Although self-signing is typical of Android applications, and a certificate authority is not required, creating a suitable key and securing it properly is critical. The digital signature for Android applications can impact certain functionality. The expiry of the signature is verified at installation time, but after it’s installed, an application continues to function even if the signature has expired.

You can export and sign your Android package file from within Eclipse using the Android Development plug-in, or you can use the command-line tools. You can export and sign your Android package file from within Eclipse by taking the following steps:

  1. In Eclipse, right-click the appropriate application project and choose the Export option.
  2. Under the Export menu, expand the Android section and choose Export Android Application.
  3. Click the Next button.
  4. Select the project to export (the one you right-clicked before is the default).
  5. On the keystore selection screen, choose the Create New Keystore option and enter a file location (where you want to store the key) as well as a password for managing the keystore. (If you already have a keystore, choose browse to pick your keystore file, and then enter the correct password.)
  6. Click the Next button.
  7. On the Key Creation screen, enter the details of the key, as shown in Figure.
  8. Exporting and signing an Android application in Eclipse.

    Exporting and signing an Android application in Eclipse.

  9. Click the Next button.
  10. On the Destination and Key/Certificate Checks screen, enter a destination for the application package file.
  11. Click the Finish button.

You have now created a fully signed and certified application package file. The application package is ready for publication.

Testing the Release Version of Your Application Package

Now that you have configured your application for production, you should perform a full final testing cycle paying special attention to subtle changes to the installation process. An important part of this process is to verify that you have disabled all debugging features and logging has no negative impact on the functionality and performance of the application.

Certifying Your Android Application

If you’re familiar with other mobile platforms, you might be familiar with the many strict certification programs found on platforms, such as the TRUE BREW or Symbian Signed programs. These programs exist to enforce a lower bound on the quality of an application.

As of this writing, Android does not have any certification or testing requirements. It is an open market with only a few content guidelines and rules to follow. This does not mean, however, that certification won’t be required at some point or that certain distribution means won’t require certification.

Typically, certification programs require rigorous and thorough testing, certain usability conventions must be met, and various other constraints that might be goo common practice or operator-specific rules are enforced. The best way to prepare for any certification program is to incorporate its requirements into the design of your specific project. Following best practices for Android development and developing efficient, usable, dynamic, and robust applications always pay off in the end—whether your application requires certification.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Android Topics