I know that it is necessary to change the version number, but when I make the change and try to generate an apk it gives an error and shows me a message ...
Error: XML version "2.0" not supported; only XML 1.0 is supported.
I know that it is necessary to change the version number, but when I make the change and try to generate an apk it gives an error and shows me a message ...
Error: XML version "2.0" not supported; only XML 1.0 is supported.
I believe you have changed this:
<?xml version="1.0" encoding="utf-8"?>
For this:
<?xml version="2.0" encoding="utf-8"?>
It is not correct because this is the version of the XML that is used in AndroidManifest . It is necessary to keep as is.
To increment the version of your application you need to define and modify two properties, but how this is done depends on how you are doing the application.
The two properties that say the version of your application are android:versionCode
and android:versionName
.
VersionCode is an integer that represents the version of your application code, relative to other versions. You can even programmatically generate this value, it's just a number that says when one application is newer than another. It has no relation to the version the user sees.
It is only used by Google Play and other stores, to know that you have been upgraded to apk
You can use the rule you want, even having spaces between versions. From experience I always increment by 1 with each update. If you upload an already used version, Google Play will reject your upload .
The VersionName is a String
that represents the release version of your application. You can use the common notation of <major>.<minor>.<point>
(eg: 2.0.1) or any other form you find convenient. As a String
you follow the order you want, which makes no difference. (The only problem is to confuse the user.)
This is the version that the user actually observes in stores.
As I've mentioned, the configuration will depend on how you build your apk.
Only modify the android:versionCode
and android:versionName
attributes in your manifest
tag:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package.name"
android:versionCode="2" <!-- Valor que as lojas usam para identificar que houve uma atualizacao -->
android:versionName="1.1"> <!-- Valor que aparece para o usuario -->
<application android:icon="@drawable/icon" android:label="@string/app_name">
...
</application>
</manifest>
With Gradle, you can set versionCode
and versionName
to build.gradle
, but remember that it will always override the value of the manifest
tag. Otherwise it is the value of the manifest
tag that will prevail.
Configuration example:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1 # Valor que as lojas usam para identificar que houve uma atualizacao
versionName "1.0" # Valor que aparece para o usuario
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
It's worth looking at the references for a better understanding.
References: