Android中的versionName和versionNumber之间的区别 [英] Difference between versionName and versionNumber in Android

查看:195
本文介绍了Android中的versionName和versionNumber之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在Android应用程序中进行了很小的更改,或者仅更改一个就足够了,是否需要更改 versionName versionNumber ?

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?

两者之间有什么区别?

推荐答案

设置应用程序版本

要定义应用程序的版本信息,请在应用程序的清单文件中设置属性.有两个属性,您应该始终为两个属性定义值:

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.

通常,您将释放版本代码设置为1的应用程序的第一个版本,然后在每个发行版中单调增加该值,而不管该发行版是主要发行版还是次要发行版.这意味着android:versionCode值不一定与用户可见的应用程序发行版非常相似(请参见下面的android:versionName).应用程序和发布服务不应向用户显示此版本值.

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.

与android:versionCode一样,系统不会将此值用于任何内部目的,只是使应用程序能够向用户显示该值.发布服务还可以提取android:versionName值以显示给用户.

此链接包含更多信息和以下示例:

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>

这篇关于Android中的versionName和versionNumber之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆