versionCode vs versionName in Android Manifest

AndroidVersionAndroid ManifestGoogle Play

Android Problem Overview


I had my app in the android market with version code = 2 and version name = 1.1

However, while updating it today, I changed the version code = 3 in the manifest but by mistake changed my version name to 1.0.1 and uploaded the apk to the market.

Now, will the users of my app get an update notification on their phones or not? Or should I redo the process again?

Android Solutions


Solution 1 - Android

Reference Link

android:versionCode

> An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute. The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number. [...]

android:versionName

> The version name shown to users. This attribute can be set as a raw string or as a reference to a string resource. The string has no other purpose than to be displayed to users. The versionCode attribute holds the significant version number used internally.

Reading that it's pretty clear that versionName is just something that's shown to the user, versionCode is what matters. Just keep increasing it and everything should be good.

Solution 2 - Android

Dont need to reverse your steps. As you increased your VersionCode, it means your application has upgraded already. The VersionName is just a string which is presented to user for user readability. Google play does not take any action depending on VersionName.

Solution 3 - Android

Version Code - It's a positive integer that's used for comparison with other version codes. It's not shown to the user, it's just for record-keeping in a way. You can set it to any integer you like but it's suggested that you linearly increment it for successive versions.

Version Name - This is the version string seen by the user. It isn't used for internal comparisons or anything, it's just for users to see.

For example: Say you release an app, its initial versionCode could be 1 and versionName could also be 1. Once you make some small changes to the app and want to publish an update, you would set versionName to "1.1" (since the changes aren't major) while logically your versionCode should be 2 (regardless of size of changes).

Say in another condition you release a completely revamped version of your app, you could set versionCode and versionName to "2".

Hope that helps.

You can read more about it here

Solution 4 - Android

Version code is used by google play store for new update. And version name is displayed to the user. If you have increased version code then update will be visible to all user.

For more detailed inform you give 2 minute reading to this article https://developer.android.com/studio/publish/versioning.html

Solution 5 - Android

I'm going to give you my interpretation of the only documentation I can find on the subject.

"for example to check an upgrade or downgrade relationship." <- You can downgrade an app.

"you should make sure that each successive release of your application uses a greater value. The system does not enforce this behavior" <- The number really should increase, but you can still downgrade an app.

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.

Solution 6 - Android

versionCode

A positive integer used as an internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName setting, below. The Android system uses the versionCode value to protect against downgrades by preventing users from installing an APK with a lower versionCode than the version currently installed on their device.

The value is a positive integer so that other apps can programmatically evaluate it, for example to check an upgrade or downgrade relationship. You can set the value to any positive integer you want, however you should make sure that each successive release of your app uses a greater value. You cannot upload an APK to the Play Store with a versionCode you have already used for a previous version.

versionName

A string used as the version number shown to users. This setting can be specified as a raw string or as a reference to a string resource.

The value is a string so that you can describe the app version as a .. string, or as any other type of absolute or relative version identifier. The versionName has no purpose other than to be displayed to users.

Solution 7 - Android

Given a version number MAJOR.MINOR.PATCH, increment the:


  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

Version Code & Version Name

As you may know, on android you have to define two version fields for an app: the version code (android:versionCode) and the version name (android:versionName). The version code is an incremental integer value that represents the version of the application code. The version name is a string value that represents the “friendly” version name displayed to the users.

Solution 8 - Android

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.

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.

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.

Solution 9 - Android

It is indeed based on versionCode and not on versionName. However, I noticed that changing the versionCode in AndroidManifest.xml wasn't enough with Android Studio - Gradle build system. I needed to change it in the build.gradle.

Solution 10 - Android

Version Code Represent Version of Your code, android OS check for update by using this variable whether this code is old or new.

Version Name Represent name of version in the format-

> (Major).(Minor).(point)

String, used for readable string only, functionally version code has been used by OS.

Solution 11 - Android

The answer from Tanoh could use some clarification. VersionCode is the equivalent of a build number. So typically an app will go through many iterations before release. Some of these iterations may make it to the Google Play store in the form of alpha, beta, and actual releases. Each successive iteration must have an incremented versionCode. However, typically you only increase the versionName when between public releases. Both numbers are significant. Your users need to know if the version they have on their phone is the latest or not (versionName) and the Play Store and CI systems such as bitrise rely on and/or update the build number (versionCode)

Solution 12 - Android

I guess the users will still get an update notification because you incremented your VERSION CODE. But your version name will be displayed as 1.0.1 to the users.

Solution 13 - Android

> In my case I show version of my application to the end users I add version name and version code in Manifest file and build.grade

<?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.mydomain.myproject"
    android:versionCode="9106"
    android:versionName="9.1.06">

   ...
 </manifest

>After that I used this variable to my activity or fragment

try
    {
        versionName =  getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;

    }
    catch (PackageManager.NameNotFoundException e) {
        versionName ="";

    }
    catch (ActivityNotFoundException e)
    {
        //e.printStackTrace();
        versionName ="";
    }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser838522View Question on Stackoverflow
Solution 1 - AndroidTanohView Answer on Stackoverflow
Solution 2 - Androiduser2517419View Answer on Stackoverflow
Solution 3 - AndroidkrishnakeshanView Answer on Stackoverflow
Solution 4 - AndroidSourabh soniView Answer on Stackoverflow
Solution 5 - AndroidbradenView Answer on Stackoverflow
Solution 6 - AndroidParesh MangukiyaView Answer on Stackoverflow
Solution 7 - AndroidPraful PatelView Answer on Stackoverflow
Solution 8 - Androidkrishan kumar SharmaView Answer on Stackoverflow
Solution 9 - AndroidChaitanyaView Answer on Stackoverflow
Solution 10 - AndroidRahul JainView Answer on Stackoverflow
Solution 11 - AndroidFuad KamalView Answer on Stackoverflow
Solution 12 - AndroidRichard KennethView Answer on Stackoverflow
Solution 13 - AndroidGanesan JView Answer on Stackoverflow