简体   繁体   English

如果我们已经在 app/build.gradle 中设置了 AndroidManifest.xml 中的 versionCode 和 versionName 需要什么?

[英]What is the need of versionCode and versionName in AndroidManifest.xml if we already set it in app/build.gradle?

Do we really need to include android:versionCode and android:versionName in AndroidManifest.xml ?我们真的需要在AndroidManifest.xml中包含android:versionCodeandroid:versionName吗?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.my.application"
  android:versionCode="1"
  android:versionName="1.0.0">

These values are indicated in my App/build.gradle under defaultConfig .这些值在我的 App/build.gradle 下的defaultConfig中指示。 I see no value in putting them in AndroidManifest.我认为将它们放入 AndroidManifest 没有任何价值。 The argument I received from colleague was, this value will be shown later in AppInfo when user tap into it.我从同事那里收到的论点是,这个值稍后会在用户点击它时显示在 AppInfo 中。

According to Android docs , I don't see any highlight about settings these in Android Manifest either.根据Android 文档,我也没有在 Android 清单中看到有关这些设置的任何亮点。

As described in the official doc :官方文档中所述:

To define the version information for your app, set values for the version settings in the Gradle build files .要为您的应用定义版本信息,请在 Gradle 构建文件中设置版本设置的值 These values are then merged into your app's manifest file during the build process.然后,这些值会在构建过程中合并到您应用的清单文件中。

Note: If your app defines the app version directly in the <manifest> element, the version values in the Gradle build file will override the settings in the manifest .注意:如果您的应用直接在<manifest>元素中定义应用版本,则 Gradle 构建文件中的版本值将覆盖 manifest 中的设置 Additionally, defining these settings in the Gradle build files allows you to specify different values for different versions of your app.此外,在 Gradle 构建文件中定义这些设置允许您为应用程序的不同版本指定不同的值。 For greater flexibility and to avoid potential overwriting when the manifest is merged, you should remove these attributes from the <manifest> element and define your version settings in the Gradle build files instead .为了获得更大的灵活性并避免在合并清单时潜在的覆盖,您应该从<manifest>元素中删除这些属性,并改为在 Gradle 构建文件中定义您的版本设置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 放置版本代码/版本名称的更好地方? build.gradle 与 AndroidManifest.xml - Better place to put versionCode/versionName? build.gradle vs AndroidManifest.xml build.gradle 和 AndroidManifest.xml 在哪里 - Where are build.gradle and AndroidManifest.xml 警告:AndroidManifest.xml已经定义了versionCode - Warning: AndroidManifest.xml already defines versionCode Android Studio AndroidManifest.xml 与 build.gradle - Android Studio AndroidManifest.xml vs build.gradle 我应该从build.gradle还是AndroidManifest.xml管理应用程序版本控制? - Should I manage app versioning from build.gradle or AndroidManifest.xml? 构建项目时,AndroidManifest.xml 文件中的 versionCode 和 versionName 会被默认值覆盖 - versionCode and versionName in AndroidManifest.xml file are overwritten with default values when project is built Android studio:为什么在AndroidManifest.xml 和build.gradle 中都指定了minSdkVersion 和targetSdkVersion? - Android studio: why are minSdkVersion and targetSdkVersion specified both in AndroidManifest.xml and build.gradle? React Native - 对 build.gradle 或 AndroidManifest.xml 的更改是否会通过快速刷新进行更新? - React Native - do changes to build.gradle or AndroidManifest.xml get updated with fast refresh? Androidmanifest.xml文件中的gradle构建错误 - gradle build error in Androidmanifest.xml file 代码中AndroidManifest.xml的用户versionName值 - User versionName value of AndroidManifest.xml in code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM