Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between versionName and versionNumber in Android

Tags:

android

Do the versionName and versionNumber have to be changed if a minor change is made in an Android Application or is it sufficient to change just one?

What is the difference between the two?

like image 798
NoviceMe Avatar asked Dec 03 '11 06:12

NoviceMe


2 Answers

Setting Application Version

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:

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

The value is an integer so that other applications can programmatically evaluate it, for example to check an upgrade or downgrade relationship. You can set the value to any integer you want, however you should make sure that each successive release of your application uses a greater value. The system does not enforce this behavior, but increasing the value with successive releases is normative.

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

* android:versionName — A string value that represents the release 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 .. string, or as any other type of absolute or relative version identifier.

As with android:versionCode, the system does not use this value for any internal purpose, other than to enable applications to display it to users. Publishing services may also extract the android:versionName value for display to users.

This link contains more information and the following example:

AndroidManifest.xml

<?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>
like image 55
user370305 Avatar answered Nov 01 '22 00:11

user370305


You don't need to change anything, but code looks nicer when you do it :)

versionName is only for user purpose, they can see it, and it need to be a string

versionCode is an integer and it's to determine which version is more recent. As long as it will be rising everything will be OK ;)

Reference Link

like image 40
Mike Avatar answered Nov 01 '22 00:11

Mike