versionCode vs versionName in Android Manifest
Asked Answered
O

12

295

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?

Olio answered 9/3, 2012 at 4:57 Comment(4)
try this link it will help you .. " developer.android.com/tools/publishing/…"Gillan
They should, as you increased the version code. Which in theory is the one used as updater marker.Mercedes
@Olio could you please mark the most voted answer as the selected answer?Marquismarquisate
@CarlosAlbertoMartínezGadea: user838522 was last seen in 2013Headachy
U
694

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.

Uyekawa answered 22/4, 2012 at 16:17 Comment(6)
That means no mathematical relation between both. Is it?Hedgehog
That explains silent updates which appears to be the same version.Void
Only to add a note: The greatest value Google Play allows for versionCode is 2100000000Leaf
Is it mandatory to mantain the version code difference between updated vesrion and previous version of app in the play store to be 1?Olav
@sivaram No. Not at all.Alleviator
@VinilChandran! Yes, there is no mathematical relation between both. But it is a good practice to make a relation between both for self understanding in future. like versionCode:1 versionName:1.0, versionCode:2 versionName:1.1 etcImmense
E
34

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.

Emcee answered 21/7, 2013 at 7:23 Comment(0)
P
34

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

Phenacaine answered 8/3, 2019 at 7:43 Comment(2)
"Say in another condition you release a completely revamped version of your app, you could set versionCode and versionName to "2"." If versionCode at this point was 137, are you then still allowed to set versionCode to 2?Papillote
you can still set the versionName to 2. But what is the point of leaving it at 2 when your versionCode already reaches 137?Lacker
M
9

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

Mellins answered 6/5, 2017 at 5:46 Comment(0)
M
8

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.

Micro answered 13/3, 2020 at 5:31 Comment(0)
C
7

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.

Cope answered 9/3, 2012 at 5:7 Comment(1)
So can I just leave it at this? Because I think the android system checks for app updates based on Version Code instead of version number. Correct me if I'm wrong.Olio
B
5

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.

Bosworth answered 30/6, 2015 at 15:2 Comment(0)
A
5

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.

Atlas answered 31/1, 2017 at 13:33 Comment(0)
H
2

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)

Halfslip answered 15/5, 2020 at 21:20 Comment(0)
C
2

versionCode is a monotonically incrementing build number per app. Each time a build (AAB) is pushed/uploaded to Google Store it has to have a unique versionCode. It is internal only to Google Play Console, so once you upload a build (AAB) with a specific versionCode, you cannot upload another build with same versionCode ever.

versionName is what gets displayed to users publicly on Google Play Store. versionName is a string and it can be anything you like you call as your app's version; it has no relation nor dependency on versionCode - both are independent of each other.

This is mentioned in versionCode, versionName on Android Developers Guide.

Cowden answered 16/6, 2023 at 6:32 Comment(0)
A
1

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 ="";
    }
Annoying answered 21/2, 2022 at 7:5 Comment(0)
P
0

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.

Podiatry answered 21/12, 2021 at 22:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.