dcsimg
December 4, 2016
Hot Topics:

Understanding Android Versioning

  • March 21, 2016
  • By Vipul Patel
  • Send Email »
  • More Articles »

Introduction

All developers dream of their application's success. The best applications are those that learn continuously from the feedback and fix the issues in the current version of the application and include them in the next versioning.

Versioning is important part of application development lifecycle. Here are some reasons that's true:

  • Versioning allows users to understand which release of the application they have on their devices and what upgrade versions are available.
  • If you have built multiple versions, each version can allow you to ask for a different set of device capabilities for each version.
  • If your application works with services, it can use the version information to make sure it uses the correct data schema to work with your service.

Basics

On the Android platform, application developers are responsible for enforcing version restrictions educating users about the version limitations. Android does support system version compatibility by honoring the minSdkVersion attribute in the AndroidManifest.xml file. This attribute can be used to specify the minimum system API that is needed for the application to build.

How to Set an Application Version

Application version can be set by using two attributes. These attributes are:

  • versionCode: This is an integer value that specifies the version of your code, compared to other versions. This allows the Android OS to check if there is a newer version available from the PlayStore, and then prompt the user to upgrade the application.
  • versionName: This is a string that represents the release version of the application code. The string value is used to display the application version in the format <major>.<minor>.<point> string. Note that this attribute is not used for any other purposes, and for all practical purposes, versionCode is used by Android.

We define the application version in the application manifest. Open up AndroidManifest.xml in the Android Project view.

Version
Figure 1: Opening AndroidManifest.xml

Open the file and make the following changes (highlighted):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.vipul.myapplication4"
   android:versionCode="1"
   android:versionName="1.0">

   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" >
      <activity
         android:name=".MainActivity"
         android:label="@string/app_name" >
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>

</manifest>

We have now specified the version of our application to be 1 for Android system, and 1.0 for users.

If the application needed a specific minimum version of the Android platform, these can also be defined in the application manifest.

The attributes that are available to specify API level requirements are as follows:

  • minSdkVersion: This is the minimum version of the Android platform on which the application can run
  • targetSdkVersion: This attribute specifies the API level on which the application is designed to run. Developers can use this version to deliver the features that can reach the most of the users. For example, if 95% of your application users use version "23", you can set the targetSdkVersion to 23 and still have minSdkVersion to be 15, to allow all users having version 15 or higher to install the application. Users with version less than 23 will not get the best experience but the application might still work.
  • maxSdkVersion: This attribute is the maximum version of the Android platform on which the application can run.

These attributes are also declared in AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.vipul.myapplication4"
   android:versionCode="1"
   android:versionName="1.0">

   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" >
      <activity
         android:name=".MainActivity"
         android:label="@string/app_name" >
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>

   <uses-sdk
      android:targetSdkVersion="21"
      android:minSdkVersion="15"
      android:maxSdkVersion="23" />

</manifest>

Developers can use these attributes to improve the outreach of their applications.

Summary

In this article, we learned about support for versioning on the Android platform. I hope you have found this information useful.

About the author

Vipul Patel is a technology geek based in Seattle. He can be reached at vipul.patel@hotmail.com. You can visit his LinkedIn profile at https://www.linkedin.com/pub/vipul-patel/6/675/508.


Tags: API, Android, application, version management, android studio, versioning, Android OS




Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel