我的应用在android市场上的版本代码为2,版本名称为1.1

但是,今天更新的时候,我在manifest里把版本码改成了3,但是错误的把我的版本名改成了1.0.1,并把apk上传到了市场。

现在,我的应用程序的用户会在他们的手机上收到更新通知吗?还是我要重做一遍?


当前回答

不需要反转你的步骤。当您增加VersionCode时,这意味着您的应用程序已经升级了。VersionName只是一个字符串,为了便于用户阅读而呈现给用户。谷歌play不会根据VersionName采取任何行动。

其他回答

我将给你我对我所能找到的关于这个主题的唯一文件的解释。

“例如检查升级或降级关系。”<-您可以降级应用程序。

你应该确保应用程序的每个后续版本都使用更大的值。系统不会强制执行此行为”<-数值应该增加,但您仍然可以降级应用程序。

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.

它确实基于versionCode而不是versionName。然而,我注意到,改变AndroidManifest.xml中的versionCode对于Android Studio - Gradle构建系统是不够的。我需要在build.gradle中更改它。

参考链接

android: versionCode

内部版本号。此数字仅用于确定一个版本是否比另一个版本更新,数值越大表示更新版本。这不是显示给用户的版本号;该数字由versionName属性设置。 取值必须为整数,例如“100”。您可以任意定义它,只要每个后续版本都有一个更高的数字。[…]

android: versionName

显示给用户的版本名。此属性可以设置为原始字符串或字符串资源的引用。字符串除了显示给用户外没有其他用途。versionCode属性保存内部使用的重要版本号。

读到这里,很明显versionName只是显示给用户的东西,versionCode才是重要的。只要不断增加,一切都会好起来的。

android:versionCode -一个整数值,代表应用程序代码的版本,相对于其他版本。

该值为整数,以便其他应用程序可以以编程方式计算它,例如检查升级或降级关系。您可以将该值设置为您想要的任何整数,但是您应该确保应用程序的每个后续版本都使用更大的值。系统不会强制执行这种行为,但是随着连续的发布而增加值是规范的。

android:versionName -一个字符串值,代表应用程序代码的发布版本,因为它应该显示给用户。

该值是一个字符串,以便您可以将应用程序版本描述为..字符串,或作为任何其他类型的绝对或相对版本标识符。

与android:versionCode一样,系统不会将此值用于任何内部目的,除了允许应用程序将其显示给用户。发布服务也可以提取android:versionName值以显示给用户。

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

在我的情况下,我向最终用户显示我的应用程序的版本,我在Manifest文件和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

之后,我将这个变量用于我的活动或片段

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

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

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