Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Android Development
Previous Page Home Next Page
 

Versioning Your Applications

Versioning is a critical component of your application upgrade/maintenance strategy.

  • Users need to have specific information about the application version that is installed on their devices and the upgrade versions available for installation.
  • Other applications — including other applications that you publish as a suite — need to query the system for your application's version, to determine compatibility and identify dependencies.
  • Services through which you will publish your application(s) may also need to query your application for its version, so that they can display the version to users. A publishing service may also need to check the application version to determine compatibility and establish upgrade/downgrade relationships.

The Android system itself does not ever check the application version information for an application, such as to enforce restrictions on upgrades, compatibility, and so on. Instead, only users or applications themselves are responsible for enforcing any version restrictions for applications themselves.

The Android system does check any system version compatibility expressed by an application in its manifest, in the minSdkVersion attribute. This allows an application to specify the minimum system API with which is compatible. For more information see Specifying Minimum System API Version.

Setting Application Version

To define the version information for your application, you set attributes in the application's manifest file. Two attributes are available, and you should always define values for both of them:

  • android:versionCode — An integer value that represents the version of the application code, relative to other versions.

    The value is an integer so that other applications can programatically evaluate it, for example to check an upgrade or downgrade relationship. You can set the value to any integer you want, however you should make sure that each successive release of your application uses a greater value. The system does not enforce this behavior, but increasing the value with successive releases is normative.

    Typically, you would release the first version of your application with versionCode set to 1, then monotonically increase the value with each release, regardless whether the release constitutes a major or minor release. This means that the android:versionCode value does not necessarily have a strong resemblence to the application release version that is visible to the user (see android:versionName, below). Applications and publishing services should not display this version value to users.

  • android:versionName — A string value that represents the release version of the application code, as it should be shown to users.

    The value is a string so that you can describe the application version as a <major>.<minor>.<point> string, or as any other type of absolute or relative version identifier.

    As with android:versionCode, the system does not use this value for any internal purpose, other than to enable applications to display it to users. Publishing services may also extract the android:versionName value for display to users.

You define both of these version attributes in the <manifest> element of the manifest file.

Here's an example manifest that shows the android:versionCode and android:versionName attributes in the <manifest> element.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
      package="com.example.package.name"
      android:versionCode="2"
      android:versionName="1.1">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        ...
    </application>
</manifest>

In this example, note that android:versionCode value indicates that the current .apk contains the second release of the application code, which corresponds to a minor follow-on release, as shown by the android:codeName string.

The Android framework provides an API to let applications query the system for version information about your application. To obtain version information, applications use the getPackageInfo(java.lang.String, int) method of PackageManager.

Specifying Minimum System API Version

If your application requires a specific minimum version of the Android platform, you can specify that version as an API Level identifier in the application's manifest file. Doing so ensures that your application can only be installed on devices that are running a compatible version of the Android system.

To specify the minimum system version in the manifest, use this attribute:

  • android:minSdkVersion — An integer value corresponding to the code version of the Android platform.

    When preparing to install an application, the system checks the value of this attribute and compares it to the system version. If the android:minSdkVersion value is greater than the system version, the system aborts the installation of the application.

    If you do not specify this attribute in your manifest, the system assumes that your application is compatible with all platform versions.

To specify a minimum platform version for your application, add a <uses-sdk> element as a child of <manifest>, then define the android:minSdkVersion as an attribute.

For more information, also see the Android System Image 1.1 Version Notes.

Android Development
Previous Page Home Next Page

 
 
  Published under the terms fo the Apache 2.0 License Design by Interspire  

   
  Published under the terms fo the Apache 2.0 License Design by Interspire