Versioning Your Applications

Quickview

  • Your application must be versioned
  • You set the version in the application's manifest file
  • How you version your applications affects how users upgrade
  • Determine your versioning strategy early in the development process, including considerations for future releases.

In this document

  1. Setting Application Version
  2. Specifying Your Application's System API Requirements

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/maintenancestrategy.

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

The Android system itself does not ever check the application versioninformation for an application, such as to enforce restrictions on upgrades,compatibility, and so on. Instead, only users or applications themselves areresponsible 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. Thisallows 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 inthe application's manifest file. Two attributes are available, and you shouldalways define values for both of them:

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

    The value is an integer so that other applications can programmaticallyevaluate it, for example to check an upgrade or downgrade relationship. You canset the value to any integer you want, however you should make sure that eachsuccessive release of your application uses a greater value. The system does notenforce this behavior, but increasing the value with successive releases isnormative.

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

  • android:versionName — A string value that represents therelease 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 ofabsolute or relative version identifier.

    As with android:versionCode, the system does not use this valuefor any internal purpose, other than to enable applications to display it tousers. Publishing services may also extract the android:versionNamevalue 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:versionCodeand 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 indicatesthat the current .apk contains the second release of the application code, whichcorresponds to a minor follow-on release, as shown by theandroid:versionName string.

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

Specifying Your Application's System API Requirements

If your application requires a specific minimum version of the Androidplatform, or is designed only to support a certain range of Android platformversions, you can specify those version requirements as API Level identifiers in the application's manifest file. Doing so ensures that your application can only be installed on devices thatare running a compatible version of the Android system.

To specify API Level requirements, add a <uses-sdk> element in the application's manifest, with one or more of these attributes:

  • android:minSdkVersion — The minimum versionof the Android platform on which the application will run, specifiedby the platform's API Level identifier.
  • android:targetSdkVersion — Specifies the API Levelon which the application is designed to run. In some cases, this allows theapplication to use manifest elements or behaviors defined in the targetAPI Level, rather than being restricted to using only those defined for the minimum API Level.
  • android:maxSdkVersion — The maximum versionof the Android platform on which the application is designed to run, specified by the platform's API Level identifier. Important: Please read the <uses-sdk>documentation before using this attribute.

When preparing to install your application, the system checks the value of thisattribute and compares it to the system version. If theandroid:minSdkVersion value is greater than the system version, thesystem aborts the installation of the application. Similarly, the systeminstalls your application only if its android:maxSdkVersionis compatible with the platform version.

If you do not specify these attributes in your manifest, the system assumesthat your application is compatible with all platform versions, with nomaximum API Level.

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

For more information, see the <uses-sdk>manifest element documentation and the API Levels document.


更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. [置顶] Android6.0权限系统
  2. 支持Android(安卓)的几款开源3D引擎调研
  3. 雷牛满面:Baidu 推出自己的移动操作系统
  4. 使用Valgrind找出Android中Native程序内
  5. Android教程-03 常见布局的总结
  6. Android之——任意时刻从子线程切换到主
  7. React Native带你从源码解决启动白屏(Andr
  8. Android开发之实现GridView支付宝九宫格
  9. GC机制,你真的了解吗?
  10. 利用Fiddler对Android模拟器网络请求进行