Shipping a Flutter app to Google Play, from upload key to production

How Run, a Flutter app, reached Google Play: one upload key, Codemagic publishing to the internal track, the build number in pubspec.yaml, then production.

By Matthew Kay//7 min read

We shipped MGKFitness: Run, a Flutter app, to Google Play by building a signed app bundle in Codemagic, uploading the first bundle to the internal testing track by hand, and letting CI publish every build after that. Build 29 was promoted from internal testing to production on 2 October 2026, and its Play page was live by 5 October. There was no closed test: the app ships from an organisation account that already had an app live.

Run recording a run: a dark street map with the route drawn in grey, and a panel reading 4.28 km, 26:30 and 6:06 per km, with Lap and Pause buttons

Where did we start?

ADR-0001 chose Flutter and planned Run as iPhone only, because Android's background location problems "would dominate the recording work". On 18 August 2026, ADR-0021 reversed that: every layout defect in the in-run screen had been found on an Android emulator, the only device the development machine could run. Recording runs in a foreground service of type location, without ACCESS_BACKGROUND_LOCATION, which the ADR notes would trigger a Play review process for a capability the app does not use.

On 10 September the Android release was still Flutter's template: debug key, APK, no publishing step. Play rejects all three, and nothing had tried to upload, so nothing had said so.

How do you sign a Flutter app for Google Play?

With an upload key you create once, on your own machine, and never generate in CI. The reason, from our Play runbook: an upload key Play has already seen cannot be swapped without a Google support request.

# Once, locally. Keep the file outside the repository, and back it up.
keytool -genkey -v -keystore upload.jks \
  -keyalg RSA -keysize 2048 -validity 10000 -alias upload

The runbook records that Play requires an upload key valid beyond 22 October 2033; ten thousand days clears that by two decades. Codemagic holds the keystore and exports its path and passwords, which the app's Gradle file reads. On a CI machine with no signing material, Gradle throws instead of falling back to the debug key, because a debug-signed bundle is "rejected only after an upload that appeared to succeed".

One upload key signs every app in the suite. Google resets a lost or compromised upload key by support request, shared or not, and one key is one secret to hold.

How does Codemagic build and publish a Flutter app to Google Play?

ADR-0020 made Codemagic the build path, so shipping never depends on being at a particular desk, with the configuration in codemagic.yaml where it can be reviewed. The Android workflow, triggered by hand, writes the app's config from secure variables, runs codegen, analysis and tests, builds a bundle and an APK, and publishes the bundle to the internal track.

# codemagic.yaml, abridged
run-android-release:
  instance_type: mac_mini_m2
  working_directory: apps/mgk_run
  environment:
    android_signing:
      - <upload keystore reference>
    groups:
      - <app config>
      - <Play service account>
  scripts:
    - name: Build AAB
      script: |
        flutter build appbundle --release \
          --dart-define-from-file=config/app_config.json
  artifacts:
    - build/app/outputs/bundle/**/*.aab
    - build/app/outputs/mapping/**/mapping.txt
  publishing:
    google_play:
      credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
      track: internal
      submit_as_draft: false

The instance is a Mac because the first build to try Linux died before starting: it "is not available with the current billing plan". The APK is kept because a bundle cannot be sideloaded. The mapping file is kept because without it Play shows obfuscated stack traces.

Why does the first upload have to be manual?

Codemagic can publish to a track but cannot create a Play listing, and the Play Developer API refuses an app whose first bundle never went through Play Console. So the publishing: block shipped commented out. Build 22 was uploaded by hand to internal testing on 10 September, and the block went live the same day.

A second ordering rule: Play will not let you create in-app products until a bundle exists, so the first bundle could not sell anything.

The first automatic publishes ran with submit_as_draft: true, meant as a safety. Build 24 went green and testers saw nothing: the track held it as a draft behind build 23, and an hour went into looking at the emulator for a fault in the release state. On 11 September the flag went to false, since the internal track already reaches only a tester list.

Who owns the build number in a Flutter app?

The +N in pubspec.yaml, and nothing else. That is ADR-0039, written down on 29 September for a rule in force since 9 September.

# apps/mgk_run/pubspec.yaml
version: 1.0.0+29  # version 1.0.0, build number 29

Before that, both release workflows passed --build-number=$PROJECT_BUILD_NUMBER, Codemagic's counter of every workflow run in the project. An iOS and an Android build of one commit got numbers one apart, and builds of the suite's other app moved Run's next number. The docs called three builds 11, 12 and 13; the binaries were 18, 19 and 20. Now the workflows pass no flag, and Play's versionCode and the iPhone build number come from one line in git. A forgotten bump fails at upload, because the store refuses a repeated number: "loud and cheap", in the ADR's words.

What shipped is a tag, run/build-N, on the commit Codemagic checked out, read off the build record. Build 25's tag once sat on a commit whose build was cancelled.

Do you need a closed test before Google Play production?

Run had none: build 29 went from internal testing straight to production. Our notes record Google's rule as applying to developer accounts registered as personal after November 2023: a closed test with 12 testers for 14 days first. Run ships from an organisation account, already verified with an app live, so production access was there from the start.

One testing rule did matter: install from Play, never by sideloading. A sideloaded build cannot take a payment, because Play Billing checks that Play delivered the app.

What does Play Console need besides the bundle?

The forms, which the runbook calls "the usual reason a first Play submission stalls". For Run:

  • A privacy policy, terms and medical disclaimer at fixed URLs. All three are generated from Markdown in the repository and served without .html in the path, because a URL in a store listing cannot be corrected without a resubmission.
  • An account deletion URL. Play requires one for any app with account creation, so someone who has uninstalled the app can still ask. Run's went up on 11 September.
  • A health disclaimer, word for word. The runbook says Google requires one paragraph verbatim for a Health & Fitness app that gives training advice. A script fails the listing if a character of it changes.
  • The App content declarations, including the foreground service, which wanted a video of a run recording with the screen off. We recorded it on an emulator and host it ourselves.
  • Android developer verification, due 30 September 2026 by Play Console's notice. Run was registered on 10 September.

How did Google Play review go?

On 2 October build 29 went from internal testing to production as one submission of eleven changes: the release, its countries, the listing and the declarations. Managed publishing was off, so it would go live on approval. One correction went in that day: the description said the run's figures sit on the lock screen, and on Android 16 a quiet notification does not by default. It now says "in a notification".

By 5 October the public Play page answered. We check that page rather than the API, because Play's API reads a release still in review as completed. No rejection is recorded.

What is the release process now?

ADR-0046, accepted on submission day:

  • develop is promoted to main when a version goes for review, so main is what was submitted.
  • A version number is submitted once. The commit after the promotion moved develop to 1.0.1+30.
  • A rejection that needs a new binary is answered by the next version, from develop. One that needs no binary is fixed in the console and resubmitted with the same build.
  • The changelog is cut at the promotion.

What went wrong along the way?

  • Tax. Play takes subscription prices exclusive of tax. Typing £0.99 showed £1.19 for the UK, 20% above the App Store. We entered £0.825 and checked the app's paywall read £0.99.
  • The product id. Play reported the subscription as run.coach.monthly:monthly, subscription and base plan, where our mapping held run.coach.monthly. The first Android purchase unlocked nothing until the logged id was added.
  • A trailing newline. Build 27's Android config step died in three seconds with "Control character in string": a variable saved with a newline, pasted into JSON by a shell heredoc. Python writes the file now.

Where does it stand?

Run 1.0.0 is live on Google Play. The iPhone version was submitted the same day from the same commit and is in App Store review. Lift 2.0.0, the suite's other app, went into review on both stores on 5 October.

The short version

  • Create the upload key once, locally, valid past 22 October 2033, and make CI refuse the debug key.
  • Upload the first bundle by hand. Then Codemagic publishes every build to the internal track.
  • Keep the build number in pubspec.yaml, not a CI counter, and tag the commit that was built.
  • An organisation account with an app already live skipped the 12-tester, 14-day closed test.
  • Submit each version number once. A rejection that needs a new binary gets the next version.
FlutterGoogle PlayCodemagicReleases

02/More build notes

More build notes