Android
An android target stamps versionName (the marketing version) and versionCode (the build number).
android: { type: "android", source: { kind: "gradle", file: "apps/mobile/android/app/build.gradle" }, verify: ["store"], store: { packageName: "com.acme.app" },}Sources
Section titled “Sources”source.kind |
Stamps | Notes |
|---|---|---|
gradle |
versionCode and versionName in defaultConfig of build.gradle or build.gradle.kts. |
The values must be literals. |
gradle-properties |
The keys VERSION_NAME and VERSION_CODE in a gradle.properties file. |
Change the names with versionNameKey and versionCodeKey. |
capacitor |
<dir>/android/app/build.gradle. |
See Capacitor. |
expo |
expo.version and expo.android.versionCode in app.json. |
See Expo. |
flutter |
version in <dir>/pubspec.yaml, which Flutter passes to Gradle. |
See Flutter. |
Bare React Native uses gradle. See React Native.
Gradle
Section titled “Gradle”launchset edits only inside android { defaultConfig { ... } }:
android { defaultConfig { versionCode 12 // changed in CI versionName "1.4.0" // changed by the release PR }}Kotlin DSL works the same (versionCode = 12, versionName = "1.4.0").
These cases are errors, with a message that names the file:
- the values are not literals (
versionCode computeVersionCode()), - they appear twice,
- product flavors override
versionNameorversionCode.
In those cases move the values into gradle.properties and use gradle-properties:
VERSION_NAME=1.4.0VERSION_CODE=12defaultConfig { versionCode project.property("VERSION_CODE").toInteger() versionName project.property("VERSION_NAME")}source: { kind: "gradle-properties", file: "apps/mobile/android/gradle.properties" },Versions and build numbers
Section titled “Versions and build numbers”- On a release,
versionNameis the release version (1.5.0). - On a preview,
versionNameis the full preview version (1.5.0-pr.123.4). On a prerelease it is the full prerelease version (1.5.0-alpha.3). versionCodeis the build number, an integer. Google Play’s maximum is 2,100,000,000. A larger number is an error. The defaulttimestampstrategy stays below it until about 2086.
See Build numbers.
Verify against Google Play
Section titled “Verify against Google Play”verify: ["store"] needs store.packageName and a service account. It opens a Play edit, lists the bundles and APKs, takes the highest versionCode, and deletes the edit.
- If this
versionCodeexists:already-publishedistrue. Your steps skip the upload andmarkstill runs. This covers “uploaded, but the job failed before marking”. - If the store’s highest number is greater than or equal to ours: the step fails and suggests a
buildNumber.offset. - Otherwise:
already-publishedisfalse.
Several apps on one Play listing
Section titled “Several apps on one Play listing”A package can hold more than one app, each on its own tracks: a phone app on internal and production, and its Android TV or Wear OS app on a form-factor track such as tv:internal. Play only needs every versionCode to be unique in the package, so each app can number its builds in its own range, but by default verify compares with the highest number in the whole package and stops the app with the lower numbers. List the tracks a target releases to in store.tracks, and the “store is ahead” check only looks at the releases on those tracks:
tv: { type: "android", source: { kind: "gradle", file: "tv/app/build.gradle.kts" }, // A range of its own, above the phone app's numbers (see the last point below). buildNumber: { offset: 1_000_000_000 }, verify: ["store"], store: { packageName: "com.acme.app", tracks: ["tv:internal", "tv:production"] },}- List every track the target’s builds go to (one per channel, if your upload step picks the track from
LAUNCHSET_CHANNEL). - A track name the app doesn’t have is an error that lists the names it does have. Form-factor tracks carry a prefix, like
tv:internalorwear:production. - “Already published” still looks at the whole package, so a retry after a newer release replaced the build on its track is recognized. A number that is in a current release on a track
store.tracksdoesn’t list is an error: either the build was promoted to a track you didn’t list (add it), or the other app took the number. Keep the apps’ number ranges apart, for example with abuildNumber.offseton one of them. - Your upload step picks the track (fastlane
supply --track tv:internal); launchset doesn’t upload. The example upload step thatinitgenerates uses the tracks’ shared prefix (tv:production,tv:beta,tv:internal) whenstore.tracksis set before you run it.
The secret LAUNCHSET_PLAY_SERVICE_ACCOUNT_JSON holds the service account’s JSON key. verify also accepts a base64-encoded copy, but store it raw when the upload step (fastlane supply, SUPPLY_JSON_KEY_DATA) uses the same secret. The generated workflow passes it to the verify step. How to create it: Google Play pipeline.
Build steps
Section titled “Build steps”- uses: actions/setup-java@v6 if: matrix.target == 'android' && steps.verify.outputs.already-published != 'true' with: { distribution: temurin, java-version: "21" }- name: Build the app bundle if: matrix.target == 'android' && steps.verify.outputs.already-published != 'true' working-directory: apps/mobile/android run: ./gradlew bundleReleaseThe generated workflow includes commented steps for the build and the upload with fastlane supply, and a failing step named Build steps missing (android) that you delete once your steps are in. channel chooses the Play track: release goes to production, prerelease to beta and preview to internal. See Workflow recipes and Store pipelines.