I am trying to find out the maximum length of both the android:versionName and android:versionCode attributes of the android manifest file?
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xxxx.xxxx" android:versionCode="185" <--- THIS ATTRIBUTE android:versionName="1.0.185"> <--- AND THIS ATTRIBUTE
Is there a maximum value or will it pretty much allow anything if there is no maximum are there certain rules in place?
Based on android documentation:
android:versionCode — An
integer value that represents the version of the application code, relative to other versions.
Edit – Android documentation explicitly states –
Warning: The greatest possible value for android:versionCode is MAXINT
(2147483647). However, if you upload an app with this value, your app
can’t ever be updated.
Based on oracle documentation:
By default, the
int data type is a 32-bit signed two’s complement integer, which has a minimum value of -2^31 and a maximum value of (2^31)-1. In Java SE 8 and later, you can use the int data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of (2^32)-1.
android:versionName — A
string value that represents the release version of the application code, as it should be shown to users.
String max length, this SO question may help you.
Update 08/11/2016 (UTC):
The docs has been updated. Not the old
MAX_INT value or the 2000000000.
Warning: The greatest value Google Play allows for
Cross-post for visibility here.
It seems there was a recent change in Google, making the maximum
versionCode up to 2000000000 only.
PS: For those who are planning to provide reference to the official documentation where the mentioned max value is 2147483647, please read the answer first in the post I referenced. It mentions that as of current date (08/10/2016), its still not updated.
Let’s look at the website.
versionCode is an integer
versionName is a String
android:versionCode — An integer value that represents the version of the application code, relative to other versions.
The value is an integer so that other applications can programmatically evaluate it, for example to check an upgrade or downgrade relationship. You can set the value to any integer you want, however you should make sure that each successive release of your application uses a greater value. The system does not enforce this behavior, but increasing the value with successive releases is normative.
Typically, you would release the first version of your application with versionCode set to 1, then monotonically increase the value with each release, regardless whether the release constitutes a major or minor release. This means that the android:versionCode value does not necessarily have a strong resemblance to the application release version that is visible to the user (see android:versionName, below). Applications and publishing services should not display this version value to users.
So the version code is an integer. It doesn’t specify the signage or the number of bits, but we can assume that it can’t be negative, and guess 32 bits. So we can guess that it can be between 0 and 2^32. Java by default has signed 32 bit integers, so that would provide values from -2^31 to 2^31. Of course, if it was a 64 bit integer, then it would be between 0 and 2^64.
android:versionName — A string value that represents the release version of the application code, as it should be shown to users.
The value is a string so that you can describe the application version as a .. string, or as any other type of absolute or relative version identifier.
As with android:versionCode, the system does not use this value for any internal purpose, other than to enable applications to display it to users. Publishing services may also extract the android:versionName value for display to users.
This one is a String, so it has no maximum value.