Maximum Length of Android versionName / versionCode (Manifest)

前端 未结 4 1434
一个人的身影
一个人的身影 2020-12-17 17:58

I am trying to find out the maximum length of both the android:versionName and android:versionCode attributes of the android manifest file?



        
4条回答
  •  暖寄归人
    2020-12-17 18:48

    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.

提交回复
热议问题