# Google Play

> Google Play takes a signed App Bundle: CI builds and verifies one on every run, signs it with your upload key from four repository secrets, and can run the game in Firebase Test Lab.

Source: https://omardev29.github.io/rmp-docs/publishing/google-play.html

Google Play takes a signed Android App Bundle — an `.aab`, not an APK, and not the debug build. CI builds, signs and verifies one on every run. With your upload key in four repository secrets, it signs with that key and a release tag attaches the bundle to the GitHub release, ready to upload in the Play Console. Nothing is uploaded to Play for you.

## The application id is permanent

Once an app is published on Google Play, its application id can never change: not renamed, not moved. A different id is a different listing, without the installs and reviews of the old one. It is `[android] application_id`:

raylib_multiplatform.toml

```toml
[android]
application_id = "com.yourname.yourgame"
```

Letters, digits and `_`, at least two parts separated by dots, each starting with a letter; no `-`, which Apple's bundle ids allow and Android's do not, so the refusal names the hyphen and writes the id the way Android takes it:

raylib_multiplatform.toml

```toml
[android]
application_id = "com.yourname.your-game"
```

```text
  raylib_multiplatform.toml:2: application_id = "com.yourname.your-game"
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  configure: error: [android] application_id = 'com.yourname.your-game' is not a valid Android application id.
                    It contains '-': an Android id takes letters, digits, '_' and '.', and nothing else.
                    A '-' is fine in an iOS bundle id and refused here: write 'com.yourname.your_game'.
                    It needs at least one dot and each segment must start with a letter, e.g. com.yourname.yourgame.
```

`rmp new` writes `com.example.` followed by the game's name, and every `com.example.` id is treated as a placeholder: `rmp deploy` refuses to tag a release under one, and so does CI when a tag is pushed by hand — `refusing to build a release with placeholder identifiers`. Only you know whether the id you replace it with is one you want to live with.

## Signing

Play needs the bundle signed with your *upload key*. You make it once, keep it, and hand it to CI as secrets.

1. **Make an upload keystore**, and keep it somewhere you will not lose it:
   ```shell
   keytool -genkey -v -keystore upload.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
   ```
   Turn on **Play App Signing** in the Play Console, so Google can reset your upload key if you do lose it.
2. **Add four repository secrets**, with exactly these names, under *Settings → Secrets and variables → Actions*:
   | Secret | Value |
   |---|---|
   | `ANDROID_KEYSTORE_BASE64` | the keystore file, base64-encoded on one line: `base64 -w0 upload.jks` |
   | `ANDROID_KEYSTORE_PASSWORD` | the keystore's password |
   | `ANDROID_KEY_ALIAS` | the key's alias — `upload` above |
   | `ANDROID_KEY_PASSWORD` | the key's password |
   ```shell
   base64 -w0 upload.jks | gh secret set ANDROID_KEYSTORE_BASE64
   gh secret set ANDROID_KEYSTORE_PASSWORD
   gh secret set ANDROID_KEY_ALIAS
   gh secret set ANDROID_KEY_PASSWORD
   ```
3. **Optionally, name the key.** Set the repository *variable* `ANDROID_SIGNER_CN` to the CN of your upload key's certificate. Without it, CI can only check that the bundle is not signed with its throwaway key — which every wrong key passes too. With it, CI checks the bundle is signed by that one.

NeverNever commit the keystore, and never write its passwords in `raylib_multiplatform.toml` or anywhere else in the repository. Whoever has the upload key and its passwords can publish as you.

### What CI does with them

The bundle is built and signed on every run, secrets or not — it is the one artifact you cannot afford to test for the first time on release day. What the secrets change is which key signs it:

|  | Signed with | Artifact of the run | On the release |
|---|---|---|---|
| No signing secrets (the default) | a throwaway key made for that run | `android-unsigned-aab`, a file ending in `-NOT-FOR-PLAY.aab` | never |
| `ANDROID_KEYSTORE_BASE64` set | your upload key | `android-release-aab` | yes, on a tag |

Either way the bundle is then checked, not trusted: `jarsigner -verify -strict` has to verify it, and the certificate that signed it is read back and compared — a run with your key fails if the bundle carries the throwaway signature, if `jarsigner` reports errors in the signer's certificate, or, with `ANDROID_SIGNER_CN` set, if the signer is anyone else. A further step reads the compiler commands Gradle used for the bundle and fails unless the game was compiled as a release.

The release build is minified, its unused resources removed, and it is not debuggable.

### Signing on your own machine

A release bundle can be built locally with Gradle. The signing configuration reads the key from the environment, never from a file in the repository:

```shell
python3 tools/configure.py
export ANDROID_KEYSTORE_FILE=/path/to/upload.jks
export ANDROID_KEYSTORE_PASSWORD=...
export ANDROID_KEY_ALIAS=upload
export ANDROID_KEY_PASSWORD=...
cd raymob && ./gradlew bundleRelease
```

Gradle writes the bundle into a build folder of its own, `raymob/app/build/outputs/bundle/release/`. Without `ANDROID_KEYSTORE_FILE` it comes out unsigned, which is fine for a look and refused by Play.

Gradle reads the game's identity from `raymob/generated.properties`, which only `tools/configure.py` writes — `rmp android` and a CMake configure run it for you. On a fresh clone, or after `rmp clean`, the file is not there and Gradle stops before building, saying to run `python3 tools/configure.py` first.

It is not the bundle a tag builds. The version comes from the tag CI is building, and a local build has none, so its version name is `0.0.0-dev` and its version code `1`: a bundle to look at, not one to upload. What goes to Play is the bundle of the tag's run.

`rmp android` builds the debug APK, which is what you install on your own phone with `adb install -r`.

## The version code

Play orders the builds of an app by its version code, and refuses an upload whose code is not higher than the last one it took — for good: a code once uploaded is spent. The code comes from the tag, `MAJOR * 1000000 + MINOR * 1000 + PATCH`, so it rises with every version you tag in order ([Releases and versions](https://omardev29.github.io/rmp-docs/publishing/releases.html#the-android-version-code) has the limits). A pre-release shares its version's code: `v1.2.0-rc1` and `v1.2.0` are both `1002000`, so upload one of them, not both. Builds that are not tags have code `1` and are not for Play.

## Uploading

The framework uploads nothing to Play: the bundle is on the GitHub release, and the Play Console is where it goes from there.

```shell
gh release download v1.2.0 --pattern '*.aab'
```

Upload it to a track in the Play Console — an internal testing track first is the quick way to put a release on your own phones before anyone else gets it — and promote it from there.

## What Play asks of the build

- **A recent target SDK.** The app targets and compiles against API 36, which Play requires of new apps and of updates from 2026-08-31. Play raises that requirement about once a year, and meeting it means moving the Android SDK, the NDK, the Android Gradle plugin and Gradle together, as one set.
- **16 KB pages.** The native code is built with NDK r28, whose default is the 16 KB ELF page alignment Play requires alongside that target.
- **The oldest Android** is `[android] min_sdk`, 24 by default (Android 7.0), between 21 and 36.
- **Who is offered the app.** `[android] gl_version` is the OpenGL ES version the game is compiled for and the one the manifest requires, so devices without it are not offered the app. `"ES20"`, the default and what `rmp new` writes, reaches every device. `"ES30"` compiles raylib and the game for OpenGL ES 3.0, links `libGLESv3` and asks the device for a version-3 context: for a game that needs what raylib's ES 3.0 path adds. `"ES31"` and `"ES32"` are refused: raylib has no 3.1 or 3.2 path, so they would compile for ES 3.0 all the same and only hide the game from more devices. `[android.features]` keeps the app from devices in the same way, for a gyroscope or an accelerometer the game cannot do without; `false` still declares the sensor, as optional.
- **What it asks for.** Every permission is visible on the listing. `[android.permissions]` has `internet` and `vibration`, both off by default; `internet` is turned on regardless when AdMob is in the build.
- **How Play files it.** `[android] category`, `"game"` by default.

## Ads, and the Data safety form

Ads are off until the game turns them on: `[android.admob] enabled` is `false` by default, and in the .toml `rmp new` writes. Its [`rmp::ads`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-ads.html) calls, if it has any, compile and do nothing. On, the Android build carries the Google Mobile Ads SDK, the `AD_ID` permission and the `INTERNET` permission with it, and the duty to declare advertising-id collection in Play's Data safety form:

raylib_multiplatform.toml

```toml
[android.admob]
enabled = true
```

With `android` switched off in `[targets]`, none of that is built, whatever `enabled` says.

The three ids, `app_id`, `interstitial_id` and `rewarded_id`, are Google's official test ids until you replace them with your own, which a game with ads does before it publishes. They go into the release build's manifest and SDK as they are written, and the SDK stops an app at startup over an app id it cannot read, so while ads are on each one has to have AdMob's shape — the app id `ca-app-pub-`, 16 digits, `~`, 10 digits; a unit id the same with a `/`. An empty id, a malformed one, or an app id and a unit id swapped is refused at its line:

raylib_multiplatform.toml

```toml
[android.admob]
enabled = true
app_id  = "ca-app-pub-3940256099942544/1033173712"
```

```text
  raylib_multiplatform.toml:3: app_id  = "ca-app-pub-3940256099942544/1033173712"
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  configure: error: [android.admob] app_id = 'ca-app-pub-3940256099942544/1033173712' is not an AdMob app id.
                    An AdMob app id looks like ca-app-pub-<16 digits>~<10 digits> -- this one has a '/', which makes it an ad unit id.
                    Copy it from the AdMob console, or set [android.admob] enabled = false.
```

The debug build never uses them. Whatever ids the .toml carries, the debug APK — the one `rmp android` builds for your own phone, and the one Firebase Test Lab's robot taps through — shows Google's test ads, because a tap on a real ad from either is invalid traffic, which is how AdMob accounts get suspended. Only the release build, the App Bundle you upload to Play, carries your ids.

Showing ads to players in the EEA or the UK requires a Google-certified consent platform, and the framework does not ship one: with ads on, that traffic is served badly or not at all until the game adds it.

## Firebase Test Lab

CI never starts the Android build itself: an emulator inside a runner with no acceleration is slow, and fails for reasons that have nothing to do with the game. Firebase Test Lab installs the APK on one of Google's devices — by default MediumPhone.arm, one of Test Lab's Arm virtual devices (an emulator Google runs, with the GPU accelerated), or the physical model `[deploy.firebase] device` names — lets its robot explore the game for up to five minutes, and reports whether it started and kept running.

It is optional, and off until it is configured:

raylib_multiplatform.toml

```toml
[deploy.firebase]
project_id = "your-gcp-project"
device     = "model=MediumPhone.arm,version=33,locale=en,orientation=portrait"
```

`project_id` is a Google Cloud project id — lowercase letters, digits and hyphens — and empty means off. `device` is the device to run on, in `gcloud`'s notation; the line above is the default. Google retires device models every few years, so check that the one you name still exists with `gcloud firebase test android models list`.

raylib_multiplatform.toml

```toml
[deploy.firebase]
project_id = "My Game"
```

```text
  raylib_multiplatform.toml:2: project_id = "My Game"
                               ^^^^^^^^^^^^^^^^^^^^^^

  configure: error: [deploy.firebase] project_id = 'My Game' must be a GCP project id (lowercase, digits, hyphens), or "" to leave it unset.
```

Setting it up, once:

1. Create or pick a Google Cloud project, and give it Blaze billing: Test Lab has no free quota.
2. Enable its APIs: `gcloud services enable testing.googleapis.com toolresults.googleapis.com`.
3. Create a service account with the roles `roles/cloudtesting.testAdmin` and `roles/cloudtoolresults.testAdmin`.
4. Create a JSON key for it, and store the whole file as the secret `GCP_SA_KEY`.
5. Optionally, set the repository variable `FIREBASE_RESULTS_BUCKET` to a Cloud Storage bucket, and give the service account `roles/storage.objectAdmin` on it: the results are written there and fetched back into the run.

The repository variables `FIREBASE_PROJECT` and `FIREBASE_DEVICE` are read too, and when set they win over the .toml.

Test Lab runs on full runs only — a tag, or a run started by hand with `full` — after the Android build. It sends the **debug** APK and refuses anything else, because the robot taps whatever it finds, ads included, and only the debug build is safe to tap: whatever ids the .toml carries, it shows Google's test ads, so the robot's taps never reach your real ad units, where AdMob would count them as invalid traffic. The results are kept with the run for seven days as `firebase-testlab-results`. A failure there fails its own job and does not hold back the release.

There is no iOS equivalent here: Test Lab needs a signed `.ipa` for iOS, and that needs an Apple developer account.
