[英]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:versionCode
和android: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.