Toolvito

Works on this device

Android Version Code Calculator

Android compares app versions by versionCode, a whole number. Choose a scheme, type MAJOR, MINOR and PATCH, and get a versionCode that grows with every new version, with the lines for your Gradle file.

Enter your values

Turn a version such as 1.4.2 into a whole-number versionCode by a fixed scheme, so that every newer version gets a higher code.

Your values

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Calculate.

How to use the calculator

  1. Choose a scheme, such as MAJOR × 10,000 + MINOR × 100 + PATCH, or type your own weights.
  2. Type MAJOR, MINOR and PATCH (and a BUILD number if your scheme has one).
  3. Choose Calculate. Copy the versionCode, or the Groovy or Kotlin lines for your build file.
  4. To read a versionCode back, choose MAJOR, MINOR and PATCH from a versionCode and use the same scheme.

How a scheme works

  • Each part of the version is multiplied by its weight, and the results are added: with MAJOR × 10,000 + MINOR × 100 + PATCH, version 1.4.2 gives 10,000 + 400 + 2 = 10,402.
  • A part must stay below the room the scheme gives it. With weights 10,000 and 100, MINOR and PATCH can go up to 99. Version 1.100.0 would give 20,000, the same code as 2.0.0, so the calculator stops you.
  • Pick a scheme once and keep it: every new release must have a higher versionCode than the last one you published.
  • The way back divides by each weight in turn: 10,402 ÷ 10,000 = 1 rest 402; 402 ÷ 100 = 4 rest 2; PATCH 2.

Limits of versionCode

  • versionCode is a positive whole number, stored as a 32-bit signed integer: at most 2,147,483,647.
  • The Android developer documentation says the largest versionCode Google Play accepts is 2,100,000,000. The calculator warns above it.
  • versionName (such as "1.4.2") is the text people see. Android does not compare it.

Worked example

Scheme MAJOR × 10,000 + MINOR × 100 + PATCH, version 1.4.2: versionCode = 1 × 10,000 + 4 × 100 + 2 × 1 = 10,402. There is room for 2,099,989,598 more before the Google Play limit, and the largest MAJOR this scheme allows there is 210,000.

Limits you should know

  • The schemes are common choices, not rules of Android. Apps that publish several APKs (for example one per ABI) often add a number for each APK; use your own weights for that.
  • The Google Play limit is quoted from the Android documentation. Check the current documentation and the Play Console before a release.
  • To compare version names such as 1.2.10 and 1.2.9, use the Version Comparator.

Related tools