Skip to content

Expert: features and shipping · Publishing on the Play Store and Firebase · topic 43 of 50 · 35 min

Release builds, signing and the App Bundle

Explanation

A release build is optimised and shrunk by R8 (isMinifyEnabled = true). Every app must be signed with a private key: you sign uploads with your upload key, and with Play App Signing Google keeps the final app signing key. Increase versionCode for every upload. Google Play requires new apps to be published as an Android App Bundle (AAB), from which Play builds small, device-specific APKs.

Debug versus release

While developing, you run debug builds: easy to debug, not optimised, signed with an automatic debug key. What you give to users is a release build: optimised, shrunk, and signed with your own key. Never upload a debug build.

R8: shrinking and obfuscation

R8 is the tool that optimises release builds. It removes unused code (shrinking), shortens names (obfuscation, which also makes reverse engineering a little harder) and optimises the remaining code. Resource shrinking removes unused images and layouts. Together they make the app smaller and faster.

kotlin
android {
    buildTypes {
        release {
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro",
            )
        }
    }
}
app/build.gradle.kts. Libraries that use reflection may need keep rules in proguard-rules.pro; test the release build carefully.

Signing and keys

Android only installs apps that are digitally signed. A signature proves who made the app and that it was not changed. Updates must be signed by the same key, or Android refuses to install them over the old version. A keystore is a password-protected file that holds keys.

KeyWho holds itUsed for
Upload keyYou (in your keystore)Signing the bundles you upload to Play Console
App signing keyGoogle, with Play App SigningSigning the APKs that users actually install

With Play App Signing (required for new apps), losing your upload key is recoverable: you can ask Google support to reset it. Still, guard it carefully: back up the keystore file and passwords somewhere safe and private, and never commit them to Git or share them in chat.

Building a signed bundle

  1. In Android Studio: Build > Generate Signed App Bundle or APK, choose Android App Bundle.
  2. Create a new keystore the first time (choose a strong password and remember the key alias), or select your existing one.
  3. Choose the release build variant and finish. The .aab file appears in app/release/.
bash
./gradlew bundleRelease
The command-line equivalent, once a signing configuration is set up (with passwords read from a private file or environment variables, never hard-coded).

Why an App Bundle?

An APK is the installable package. An Android App Bundle (.aab) is a publishing format that contains all your code and resources. Google Play uses it to generate optimised APKs for each device, with only the screen density, CPU type and languages that phone needs. Users download less, which matters on slow or expensive mobile data. New apps on Google Play must be published as AABs (required since August 2021).

Versioning

versionCode is an integer that must increase for every upload; Play Console rejects a bundle whose versionCode it has already seen. versionName ("1.2.0") is the friendly version users see. A common habit is to bump versionCode by one for each release and follow MAJOR.MINOR.PATCH for versionName.

Think of it like this: Signing is like a company seal on official documents. The upload key is your office seal that you stamp on parcels sent to Google; the app signing key is the final seal Google stamps on what reaches customers. If someone else could stamp your seal, they could send fake parcels in your name, so keep the seal locked away.

Common mistakes

  • Committing the keystore or its passwords to GitHub. Add them to .gitignore and store them privately.
  • Forgetting to increase versionCode: "Version code 3 has already been used".
  • Not testing the release build: R8 can remove classes used by reflection, causing crashes only in release.
  • Uploading an APK for a new app: Play requires an AAB.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Release builds, signing and the App Bundle · 1/7

Debug ≠ Release

Users get release builds: optimised, shrunk and signed with your key. Never upload a debug build.

Prefer a video by a teacher? Find free videos on “android generate signed app bundle play app signing release build r8” on YouTube ↗

In real life: The first release of a tiffin service app

A home-food delivery startup prepares version 1.0 of its app. The developer enables R8, builds a release bundle on a real phone and finds one crash caused by a JSON model stripped by R8, fixed with a keep rule. She creates the upload keystore, stores it and its passwords in the company password manager with a backup, and uploads the signed .aab with versionCode 1. The app drops from 18 MB (debug) to about 7 MB download size.

kotlin
android {
    defaultConfig {
        versionCode = 1
        versionName = "1.0.0"
    }
}
Next update: versionCode = 2, versionName = "1.0.1".

Practice (0/3 done)

Task 1 · Question

Play Console says "Version code 5 has already been used". What should you do?

Task 2 · Question

Which format must new apps use on Google Play?

Task 3 · Practice

For one of your apps: enable R8 and resource shrinking, generate a signed App Bundle with a new upload keystore, install a release build on your phone (for example by building a signed release APK for local testing) and test every screen. Write down where you stored the keystore backup (without the passwords).

Quick quiz

Question 1

1.What does R8 do?

Question 2

2.With Play App Signing, who holds the app signing key?

Question 3

3.Why must updates be signed with the same key as the original app?

Question 4

4.What is the benefit of an App Bundle for users?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What does R8 do?

Answer: Shrinks, obfuscates and optimises release code

R8 is the release optimiser.

With Play App Signing, who holds the app signing key?

Answer: Google

You keep the upload key; Google keeps the app signing key.

Why must updates be signed with the same key as the original app?

Answer: Android only accepts updates from the same signer, which proves they come from you

The signature is the app's identity.

What is the benefit of an App Bundle for users?

Answer: Smaller downloads tailored to their device

Play delivers only what each device needs.

With Play App Signing, which key do you keep?Related

Answer: The upload key

Google holds the app signing key.

From Publishing on Google Play

Does obfuscation keep API keys in the app safe?Related

Answer: No; secrets in an app can still be extracted

Keep secrets on the server.

From Preparing a release

What do reviewers most often check first in a take-home Android app?Related

Answer: Whether it runs, handles states and rotation, and has clean structure

Working basics and clean structure matter most.

From Interview questions: Android and Compose

Where do you explain why the app needs the camera on iOS?Related

Answer: A usage description key in Info.plist

For example NSCameraUsageDescription.

From Publishing on the Apple App Store

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 3 more topics in “Publishing on the Play Store and Firebase” before its exam: Google Play Console and testing tracks, Play policies: privacy, data safety and targets, Firebase basics.
  2. Module 11 exam: Publishing on the Play Store and Firebase · 13 questions · 25 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, Android career path. 50 topics left in the course before the final exam.

← Previous: Debugging and performance