January 17, 2011
peracha
Whether you have a bug fix, enhancement or performance optimization that you want to deliver to your customers, one of your Android apps will inevitably require an upgrade. This can be either a seamless process or a painful one for your customers. To ensure that it is the former and not the latter, the Android SDK provides some simple guidelines to help you manage this process. Last week, we discussed some useful configuration settings offered through AndroidManifest.xml for designing apps to run on smartphones and tablets. This same configuration file also provides settings to version your apk.
There are two attributes you can specify to manage the versioning process of your app:
The versionName attribute is a user facing string that identifies the version of the application in use. For example, if you are upgrading for the first time, your previous versionName may be “1.0” while a minor upgrade version would be indicated by “1.1” and a major upgrade by “2.0”. The versionName attribute is primarily used for display purposes and helps users identify differences between app versions. The following is a snippet of the manifest from the Amazon MP3 App for Android:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazon.mp3"
android:versionCode="80029"
android:versionName="1.8.29">
...
</manifest>
The versionCode is the attribute that is used by the Amazon Appstore for Android to compare versions of your app. This is an integer, like 80029 in the sample manifest, not a string like the versionName. If the versionCode of an apk is greater than the versionCode of another apk, then it is considered to be newer. Of course, for this comparison to be valid, the apk package name and signature must also match. To avoid unexpected behavior, it is extremely important to keep track of your versionCode and to always increase the value whenever you are releasing a new version.