page.title=Versioning Your Applications @jd:body

Versioning quickview

See also

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

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

The Android system itself does not ever check the 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.

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}.

If your application requires a specific minimum version of the Android platform, you can also specify that in the manifest file:

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. Currently, only one platform version has been released for mobile devices — that version is "1". For this reason, you do not need to define this attribute in your application and, at this point, defining it is not recommended.