您的位置:首页 > 移动开发 > Android开发

android 开发中获取versionName和versionCode

2016-09-07 13:37 267 查看
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中的配置。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: