What is Versioning?
Versioning is a very important method used to control and specify changes in any application and the Android SDK provides you with a very easy way to specify versions in your applications. Versioning is very useful if you intend to upgrade or maintain your applications and it is also used in the Android Market when you publish your application. It is also used in the Android Market to automatically offer application upgrades. Another use of versioning is to check for compatibility and dependency issues between applications.
Android borrows heavily from the Java style of programming, which is evident from the similarity between the two. Android provides a versioning mechanism very similar to JAR packages in Java. To specify versions and other application specific details in Android APK application packages, you need to edit the AndroidManifest.xml file which can be found in the root directory of the application. This is analogous to the Manifest.mf file found in JAR packages in Java.
The AndroidManifest.mf is an XML file used to store the information about any application. While it stores many details, there are two main attributes which are used to specify the version details. It is located in the root directory of your application’s APK file.
This attribute is an integer value which is used to specify the version of the application relative to other versions. You can increment this in each new version to show a upgrading relationship between them. It isn’t accessible by the users and is only used by the system.
This attribute is a string value which represents the exact version number of the application. This value is used to display version information to the users. It can be of the format ..
Both these attributes are defined in the manifest element in AndroidManifest.xml.
Here’s an example of the AndroidManifest.xml file:
The attributes are highlighted in bold. In this example, the versionCode is 5 and the versionName is 1.2.1.