Apqu Apqu - 1 year ago 160
Android Question

Maximum Length of Android versionName / versionCode (Manifest)

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"
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?

Answer Source

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.

Regarding String max length, this SO question may help you.