现在您可以将 versionCode
和 versionName
放入 build.gradle
和 AndroidManifest.xml
文件中。其中哪一个是放置这些属性的最佳位置,为什么它比其他选项更好?
我在谷歌官方文档中找不到任何相关信息:
https://developer.android.com/tools/building/configuring-gradle.html
http://developer.android.com/guide/topics/manifest/manifest-element.html
非常感谢。
最佳答案
实际上并没有什么不同。但我会告诉你一些关于这方面的信息。
如果你在 AppManifest.xml 和 build.gradle 中都写了你的 versionCode 和 versionName,那么当你编译你的应用程序时,build.gradle 中写的将替换你 AppManifest.xml 中的那些,这里来了第 2 点。
如果您没有将它们写入您的 AppManifest.xml,当您编译您的应用并构建它时,您在 build.gradle 中编写的 versionCode 和 versionName 将自动写入您的 AppManifest.xml。
如果您只在 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/