The Android version has two independent parts:
versionNameis the user-facing SemVer-style string:major.minor.patch[-suffix].versionCodeis the integer used by Google Play to order artifacts.
The source of truth is the root gradle.properties file:
APP_VERSION_MAJOR=0
APP_VERSION_MINOR=1
APP_VERSION_PATCH=0
APP_VERSION_SUFFIX=
APP_VERSION_CODE=1This configuration produces versionName = 0.1.0 and versionCode = 1.
- Increment
APP_VERSION_PATCHfor backward-compatible bug fixes. - Increment
APP_VERSION_MINORfor backward-compatible features and reset patch to0. - Increment
APP_VERSION_MAJORfor incompatible product changes and reset minor and patch to0. - Set
APP_VERSION_SUFFIXto a prerelease identifier such asbeta,rc.1, ordev. Leave it empty for a stable release. - Increase
APP_VERSION_CODEfor every upload to Google Play. Never reuse a code, even when only the suffix changes.
The branch, merge and tag flow for a release is described in RELEASING.md.
Examples:
| Properties | Result |
|---|---|
0.1.0, empty suffix, code 1 |
0.1.0, versionCode 1 |
0.1.0, suffix beta, code 2 |
0.1.0-beta, versionCode 2 |
0.1.1, suffix beta, code 3 |
0.1.1-beta, versionCode 3 |
0.1.1, empty suffix, code 4 |
0.1.1, versionCode 4 |
Gradle properties can be overridden without changing the checked-in defaults:
./gradlew bundleRelease \
-PAPP_VERSION_MAJOR=0 \
-PAPP_VERSION_MINOR=1 \
-PAPP_VERSION_PATCH=0 \
-PAPP_VERSION_SUFFIX=beta \
-PAPP_VERSION_CODE=2The versionCode should be stored in the release system or another persistent source so that parallel builds cannot reuse it.