如何定义android项目的版本号?

How to define the number of version code for android project?

build.gradle 文件中,有一个名为versionCode 的属性。每当我对项目进行更新时,我是否应该增加 versionCode 的值?

您应该为计划在 Google Play(或您使用的任何其他分发渠道)上发布的任何新版本增加版本代码,作为对现有版本的更新。对于内部测试,您不必增加版本代码,因为您可以强制重新安装。

如果您计划将您的应用发布到 Playstore,那么每次更新都必须有不同的 verionCode 和 versionName 只是供开发人员跟踪主要更改和更新。

版本号只有在发布应用时才需要增加,否则不需要增加。您可以继续使用相同的版本代码

android:versionCode —

An integer value that represents the version of the application code, relative to other versions.

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. Applications and publishing services should not display this version value to users.

versionCode 在 Play 商店开发者控制台的屏幕截图:

android:版本名称 —

A string value that represents the release version of the application code, as it should be shown to users.

Play 商店已发布应用中 versionName 的屏幕截图:

总结: 版本号用于跟踪您的应用程序更新,基本上在您在 Play 商店上传新 apk 时使用。另一方面,versionName 是一个对用户可见的字符串,因此他们可以看到有可用的新版本。

来源:Versioning Your Applications