android - 放置版本代码/版本名称的更好地方? build.gradle 与 AndroidManifest.xml

标签 android gradle android-manifest android-gradle-plugin build.gradle

现在您可以将 versionCodeversionName 放入 build.gradleAndroidManifest.xml 文件中。其中哪一个是放置这些属性的最佳位置,为什么它比其他选项更好?

我在谷歌官方文档中找不到任何相关信息:

  1. https://developer.android.com/tools/building/configuring-gradle.html

  2. http://developer.android.com/guide/topics/manifest/manifest-element.html

非常感谢。

最佳答案

实际上并没有什么不同。但我会告诉你一些关于这方面的信息。

  1. 如果你在 AppManifest.xml 和 build.gradle 中都写了你的 versionCode 和 versionName,那么当你编译你的应用程序时,build.gradle 中写的将替换你 AppManifest.xml 中的那些,这里来了第 2 点。

  2. 如果您没有将它们写入您的 AppManifest.xml,当您编译您的应用并构建它时,您在 build.gradle 中编写的 versionCode 和 versionName 将自动写入您的 AppManifest.xml。

  3. 如果您只在 AppManifest.xml 中编写它们,则不会发生任何事情。已经写好了……

总而言之,build.gradle 覆盖您的 AppManifest.xml。

希望对您有所帮助。

来源:https://developer.android.com/studio/publish/versioning

Note: If your app defines the app version directly in the element, the version values in the Gradle build file will override the settings in the manifest. Additionally, defining these settings in the Gradle build files allows you to specify different values for different versions of your app. For greater flexibility and to avoid potential overwriting when the manifest is merged, you should remove these attributes from the element and define your version settings in the Gradle build files instead.

关于android - 放置版本代码/版本名称的更好地方? build.gradle 与 AndroidManifest.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32138225/

相关文章:

安卓工作室 : "Cannot resolve symbol" registering service in manifest

android - 多个应用程序,共享同一数据目录

javascript - Jquery Mobile - 从其他按钮单击更改标题中的图标颜色

grails - 服务器和应用程序的消息在 Intellij 2016 中显示在哪里?

maven - gradle是否使用.m2/settings.xml中的镜像设置

没有 GUI 的 Android 应用程序

android - 如何避免对 APK 文件进行逆向工程

java - 将 Android 应用程序作为库包含在另一个应用程序中时,谷歌地图不起作用

java - 保存截图 cocos2d-x android

compilation - 如何在 Gradle 中定义*仅*编译时类路径?