Skip to content
← All posts

By Specita

Android version code vs version name: rules and examples

Android version code vs version name: what each does, the 2100000000 limit, why Google Play rejects a reused code, and how to set both in Gradle and Flutter.

A clay staircase of many thin steps beside an ivory paper tag on an ink thread with a terracotta dot.

On Android, the version code is an integer the system and Google Play use to tell which build is newer. The version name is the string users see, such as 2.4.0. Google Play rejects a version code you have already used, and users only receive an update when its version code is higher than what's installed. The version name has no such rules, so it can even repeat.

The details below follow Google's documentation. Check Android's versioning guide for the current rules.

Android version code vs version name at a glance

versionCodeversionName
TypePositive integerString
Used byAndroid and Google PlayPeople
Shown to usersNoYes
Must increaseYes, for updates to installNo
Maximum2100000000No such limit in the guide
Example20400172.4.0

Android's guide describes versionCode as an internal version number, where higher numbers are more recent. You can't upload to the Play Store with a versionCode you have already used for a previous version. The free App Version Number Helper checks a version code against the maximum.

Setting them in Gradle

Set both in your module's build.gradle.kts or build.gradle:

android {
    defaultConfig {
        versionCode = 317
        versionName = "2.4.0"
    }
}

Google advises defining these in Gradle, and not in the manifest. Gradle values override the manifest, and Google says that keeping them in Gradle avoids overwriting problems when the manifest is merged. You can also give product flavors different version names, such as 1.1-demo.

In Flutter, pubspec.yaml sets both:

version: 2.4.0+317

The part before the plus sign is the version name, and the part after it is the version code. The same number becomes the iOS build number on an iOS build. That means one number has to satisfy both platforms. You can override both at build time with --build-name and --build-number.

A numbering scheme that won't trap you

The version code has to rise forever, and you can't go back. Two schemes are common.

The first is a simple counter, using your CI run number or a stored value. It's easy to understand and hard to get wrong. Your CI's run number can reset if you move systems, so add an offset big enough to clear your highest code when you migrate.

The second encodes the version: major × 1000000 + minor × 10000 + patch × 100 + build, so 2.4.0 build 17 becomes 2040017. You can read the version from the code. The cost is that you need to plan ahead for how big each part can get, and your hotfix on an older line must still be higher than what's live.

Watch the ceiling if you encode dates or other large values. A Unix timestamp in seconds is already above 1790000000, close to the 2100000000 limit, and once you've uploaded a high number, you can't come back down. A hypothetical example: a developer sets a code of 2026110412 from the date and hour. It's valid today, but the maximum is close, and everything afterward has to be higher than that.

Why a release can fail on the version code

Error or symptomCauseFix
"Version code has already been used"A repeat upload, including to another trackIncrement, then rebuild
Testers don't get the new buildA higher version code exists on another track they're eligible forCheck codes across release tracks
Update won't installVersion code is lower than the installed oneShip a higher code. Users can't downgrade through Play
The Play Console says the release doesn't replace anotherAnother active release has a higher codeCheck the release's included bundles

A version code is used once it's uploaded, even if the release never went out. A failed CI run that uploaded successfully still spends its number. Read the current maximum from the Play API or Play Console if your pipeline needs to be sure.

Hotfixes and rollbacks

You can't publish the older code to undo a bad release. To roll back, you take the old source and ship it with a new, higher version code and usually a new version name. See iOS app rollback for the same idea on Apple's side, and Google Play staged rollout for how halting fits in. Halting doesn't remove the release from users who already have it.

A line of work on an older version needs care. If 2.4.0 has code 2040017 and 2.5.0 has 2050003, then a hotfix 2.4.1 with code 2040101 is lower than 2.5.0. Users already on 2.5.0 won't get it, which may be exactly what you want. But if 2.5.0 is only in closed testing, your production users on 2.4.0 do get it. Think through who is on which track.

Why the version name still matters

Android doesn't care about the version name, but people do. It's what your support team asks for and what clients read. It also often forms your crash reporting release name. Keep the format consistent, such as three numbers. If a suffix helps internally, such as 2.4.0-rc1, keep it off production builds so that your release records stay comparable.

Match the name across iOS and Android when you can. Your support team will thank you when "2.4.0" means the same thing on both.

Connecting it to the rest of the release

Google Play's release name defaults to the version name of the first bundle you add to a release. If you keep that default, your Play Console, your Git tags, and your crash tool can share one identifier.

Specita matches each Google Play release to an Android version by release name, or when the version ends in the Google Play version code, such as 1.0.1+7. A consistent format keeps your store data attached to the right release. The Google Play setup guide has the details.

Google guidance checked on November 4, 2026.