android studio中gradle文件和manifest中都有对于versionName和versionCode的配置。
经过实践发现使用PocketManager get PocketInfo中的versionName是gradle配置的,查阅官方文档发现gradle中的配置在build的时候会覆盖manifest中的。
To define the version information for your app, set values for the version settings in the Gradle build files. 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. 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 <manifest>
element and define your version settings in the Gradle build files instead.
Two settings are available, and you should always define values for both of them:
所以可以删除manifest中的配置,直接使用gradle中的配置。