如何更改Android版本和代码版本号?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22274657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change Android version and code version number?
提问by Marko Stojkovic
How to change Android version and code version number Android Studio? I want to change apk file (app) on Google Play and I need to change Android version and code version number. I tried with this in AndroidManifest.xml file in Android Studio:
如何更改Android版本和代码版本号Android Studio?我想更改 Google Play 上的 apk 文件(应用程序),我需要更改 Android 版本和代码版本号。我在 Android Studio 的 AndroidManifest.xml 文件中尝试过这个:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bestsoftcorporation.circle.app"
android:versionCode="101"
android:versionName="2.0">
But it does not work. When I tried to publish it on Google Play it display that I must to change Android version name and code.
但它不起作用。当我尝试在 Google Play 上发布它时,它显示我必须更改 Android 版本名称和代码。
回答by Ajay S
Go in the build.gradleand set the version code and name inside the defaultConfig
element
进入build.gradle并在defaultConfig
元素内设置版本代码和名称
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
回答by Ivo Stoyanov
The easiest way to set the version in Android Studio:
在 Android Studio 中设置版本的最简单方法:
1. Press SHIFT+CTRL+ALT+S (or File -> Project Structure -> app)
1. 按 SHIFT+CTRL+ALT+S(或文件 -> 项目结构 -> 应用程序)
Android Studio < 3.4:
Android Studio < 3.4:
- Choose tab 'Flavors'
- The last two fields are 'Version Code' and 'Version Name'
- 选择标签“口味”
- 最后两个字段是“版本代码”和“版本名称”
Android Studio >= 3.4:
Android Studio >= 3.4:
- Choose 'Modules' in the left panel.
- Choose 'app' in middle panel.
- Choose 'Default Config' tab in the right panel.
- Scroll down to see and edit 'Version Code' and 'Version Name' fields.
- 在左侧面板中选择“模块”。
- 在中间面板中选择“应用程序”。
- 在右侧面板中选择“默认配置”选项卡。
- 向下滚动以查看和编辑“版本代码”和“版本名称”字段。
回答by pyus13
You can define your versionName
and versionCode
in your module's build.gradle
file like this :
您可以像这样在模块文件中定义您的versionName
和:versionCode
build.gradle
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
.... //Other Configuration
}
回答by Masoud.Ebrahimi
Press Ctrl+Alt+Shift+S in android studio or go to File > Project Structure...
Select app on left side and select falvors tab on right side on default config change version code , name and etc...
在 android studio 中按 Ctrl+Alt+Shift+S 或转到 File > Project Structure... 在左侧选择应用程序,然后在默认配置更改版本代码、名称等右侧选择 falvors 选项卡...
回答by bonnyz
You can manage your application versioning wiselyby using the Advanced Build Version Pluginfor Gradle.
您可以使用Gradle的高级构建版本插件明智地管理应用程序版本。
You just need to include the plugin in yout build.gradle
:
你只需要在你中包含插件build.gradle
:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.moallemi.gradle.advanced-build-version:gradle-plugin:1.5.0'
}
}
apply plugin: 'org.moallemi.advanced-build-version'
And then you can use the versioning functions (and, obviously, customizethem):
然后您可以使用版本控制功能(并且,显然,自定义它们):
advancedVersioning {
nameOptions { }
codeOptions { }
outputOptions { }
}
def appVersionName = advancedVersioning.versionName
def appVersionCode = advancedVersioning.versionCode
For more information, take a look at the official documentation.
有关更多信息,请查看官方文档。
回答by Egor
回答by rajlaxmi_jagdale
Go in the build.gradle and set the version code and name inside the defaultConfig element
进入 build.gradle 并在 defaultConfig 元素中设置版本代码和名称
defaultConfig { minSdkVersion 9 targetSdkVersion 19 versionCode 1 versionName "1.0" }
defaultConfig { minSdkVersion 9 targetSdkVersion 19 versionCode 1 versionName "1.0" }
回答by Bj?rn Kjos-Hanssen
I didn't get the other answers to work in Android Studio 1.4. But this worked:
click on your app name to the left below the main ribbon.
It will show a list of files.
Open AndroidManifest.xml
and change the version code and version number there.
我没有得到在 Android Studio 1.4 中工作的其他答案。但这有效:单击主功能区下方左侧的应用程序名称。它将显示文件列表。AndroidManifest.xml
在那里打开并更改版本代码和版本号。
回答by Vishwani
After updating the manifest file, instead of building your project, go to command line and reach the path ...bld\Debug\platforms\android. Run the command "ant release". Your new release.apk file will have a new version code.
更新清单文件后,不要构建项目,而是转到命令行并到达路径 ...bld\Debug\platforms\android。运行命令“ant release”。您的新 release.apk 文件将具有新的版本代码。
回答by Val
Android version and code version number change on Android Studio >= 3.6:
Android Studio >= 3.6 上的 Android 版本和代码版本号更改:
Two ways to achieve this:
实现这一目标的两种方法:
Direct on the Android project by Open Flutter project and modify the file
local.properties
直接在Android项目上通过Open Flutter项目修改文件
本地属性
change the following values. Example:
更改以下值。例子:
flutter.buildMode=release
flutter.versionName=3.0.0
flutter.sdk=C\:\src\flutter
sdk.dir=C\:\Users\vgonza\AppData\Local\Android\sdk
flutter.versionCode=30
- Open pubspec.yaml
- 打开 pubspec.yaml
Change the
改变
version: 2.0.0+8
Meaning: The version name is 2.0.0 The version code is 8
含义:版本名称为 2.0.0 版本代码为 8
See example by Suragch in:
参见 Suragch 的示例: