page.title=Versioning Your Applications @jd:body

Versioning quickview

In this document

  1. Setting Application Version
  2. Specifying Minimum System API Version

See also

  1. Preparing to Publish Your Application
  2. Publishing On Android Market
  3. The AndroidManifest.xml File

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

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:

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="http://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 {@link android.content.pm.PackageManager#getPackageInfo(java.lang.String, int)} method of {@link android.content.pm.PackageManager 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:

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.