Is there a max value for versioncode?

2019-03-17 18:09发布

We always have to increment versionCode by some arbitary number to publish it to google play.
Is there limit to that value and what will happen if it is reached?

defaultConfig {
        applicationId "my.app"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 65
        versionName "1.05"
        setProperty("archivesBaseName", "myapp-$versionCode")

    }

3条回答
再贱就再见
2楼-- · 2019-03-17 18:58

Starting at Android P, the version code will be a long (source). The max value of a long is 9,223,372,036,854,775,807 so you shouldn't run into any issues regarding length here.

Do note that it's still an int in older android versions, so this is only relevant to you when your minSdkVersion is Android P or higher.

查看更多
孤傲高冷的网名
3楼-- · 2019-03-17 19:12

Update 08/11/2016 (UTC):

The docs has been updated. Not the old MAX_INT value nor the 2000000000.

Warning: The greatest value Google Play allows for versionCode is 2100000000.


Cross-post for visibility here.

It seems there was a recent change in Google, making the maximum versionCode up to 2000000000 only.

Reference post: Google Play Developer Console error: The version code of your APK is high and you risk not being able to update your APK


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.

查看更多
放我归山
4楼-- · 2019-03-17 19:14

According to android documentation and the gradle DSL documentation:

android:versionCode — An integer value that represents the version of the application code, relative to other versions.

Checking the java doc, 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.

Then the maximum value is 2^31-1.

查看更多
登录 后发表回答