Question:
I know 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.
Answer:
I believe you have changed this:
<?xml version="1.0" encoding="utf-8"?>
For this:
<?xml version="2.0" encoding="utf-8"?>
This is not correct, as this is the version of the XML that is used in AndroidManifest . It is necessary to keep it as it is.
To increase your application's version you need to set and modify two properties, but the way this is done depends on how you are doing the application build.
The two properties that tell the version of your app are android:versionCode
and android:versionName
.
VersionCode
VersionCode is an integer that represents the version of your application's code, relative to other versions. You can even programmatically generate this value, it's just a number that tells you when one app is newer than another. It has nothing to do with the version the user sees.
It is only used by Google Play and other stores, to know that there was an update on the apk you sent, thus making the distribution.
You can use whatever 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 .
VersionName
The VersionName is a String
representing 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 see fit. As it is a String
you can 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 sees in stores.
As I mentioned, the configuration will depend on how you build your apk.
If you use ADT
Just modify the android:versionCode
and android:versionName
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>
If you use Gradle
With Gradle, you can set the versionCode
and versionName
in build.gradle
, but remember that it will always overwrite the manifest
tag value. Otherwise it is the manifest
tag value 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:
- http://developer.android.com/tools/publishing/versioning.html
- http://developer.android.com/tools/building/configuring-gradle.html