Difference between versionName and versionNumber in Android

后端 未结 3 1914
予麋鹿
予麋鹿 2021-02-05 07:13

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?

相关标签:
3条回答
  • 2021-02-05 07:53

    Android App Manifest documentation:

    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 number 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.

    0 讨论(0)
  • 2021-02-05 07:55

    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>
    
    0 讨论(0)
  • 2021-02-05 08:06

    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

    0 讨论(0)
提交回复
热议问题