12AppTesting logo12AppTestingClosed Testing Service
HomeAboutHow It WorksPricingBlogFAQContact
Home › Blog › How to Create an AAB File for Google Play (Android Studio)

How to Create an AAB File for Google Play (Android Studio)

Quick answer To create an AAB file for Google Play, open Android Studio, choose Build > Generate Signed App Bundle / APK, select Android App Bundle, sign it with your upload keystore and build the release variant.
Illustration for the guide: How to Create an AAB File for Google Play (Android Studio)

Google Play no longer takes APK files for new apps. It wants an Android App Bundle, a file ending in .aab. If you have only ever built APKs, the switch can feel confusing: where do you click, what is a keystore, and why does Play Console say your file is not signed correctly? This guide walks you through creating an AAB file for Google Play from start to finish, with the checks that prevent the most common upload errors.

What is an AAB file for Google Play?

An Android App Bundle is a publishing format. It contains all your compiled code and resources, but Google Play builds and signs the optimized APKs that reach each user's phone. Google's app bundle documentation explains the benefit: only the code and resources a device needs are downloaded, so users get smaller downloads and you do not manage many APKs yourself.

AAB (app bundle)APK
PurposeUpload to Google PlayInstall directly on a device
Who builds the final APKsGoogle PlayYou
Required for new apps on Google PlayYes (since August 2021)No
Installable on a phone by itselfNo. Use bundletool or Google Play.Yes
Typical download size for usersSmaller, device-specificLarger if one universal APK

What do you need before you build the bundle?

  • A final applicationId. This is your package name, for example com.yourname.myapp. It cannot be changed after you publish.
  • versionCode and versionName set in the defaultConfig block of your module's build.gradle. versionCode must be a positive integer that goes up with every release. versionName is the text users see.
  • A release build type without debug flags.
  • An upload keystore (a .jks file), a key alias and the passwords. You will create one in the steps below if you do not have it.
  • A developer account with the app created in Play Console. See how to publish an app for the first time.

Google's versioning documentation is clear on the rule: you cannot upload with a versionCode you have already used, and the greatest value Google Play allows is 2100000000. A simple habit is to add 1 for every upload, even for test builds.

android {
    defaultConfig {
        applicationId = "com.yourname.myapp"
        versionCode = 1
        versionName = "1.0"
    }
}

How do you generate a signed AAB in Android Studio?

Menu names change between Android Studio versions, so if yours looks different, search the Build menu for the signed bundle option.

  1. Open the Build menuChoose Build > Generate Signed App Bundle / APK.
  2. Choose Android App BundleSelect Android App Bundle and click Next.
  3. Create or choose a keystoreTo make a new one, click Create new, choose a file location and passwords, set an alias and a validity of at least 25 years, and fill in your name or organization. To reuse one, click Choose existing and enter its passwords.
  4. Back up the keystore immediatelyCopy the .jks file and passwords to at least two safe places. Do not store them only on one laptop.
  5. Select the release variantChoose release as the build variant, then click Create (or Finish).
  6. Wait for the buildWhen it finishes, Android Studio shows a notification. Click locate to open the folder with your .aab file.
Protect the keystore: Your upload key proves to Google that an upload came from you. If you lose it you can request a reset, but that takes time. Never commit the keystore or its passwords to a public repository. Read what you must keep safe.

How do you build the AAB with Gradle?

From a terminal in the project folder you can build the bundle without opening the signing wizard, once signing is configured. Google's command-line build page describes the pattern: bundle followed by the variant name. For a release build in a standard single-module app:

./gradlew bundleRelease

On Windows use gradlew instead of ./gradlew. To sign the release build automatically, define a signingConfigs block and assign it to the release build type. Keep the passwords out of the file you commit: read them from a local properties file or environment variables instead. Google's page also warns that passwords written into a build file are visible to anyone who can read it.

Command or toolUse it for
./gradlew bundleReleaseBuild a release app bundle
./gradlew bundleDebugBuild a debug bundle for your own testing, never for Play
keytool -genkey ... -keyalg RSA -keysize 2048Create an upload keystore (RSA, at least 2048 bits)
jarsignerSign a bundle manually. Google says apksigner cannot sign app bundles.
bundletoolGenerate APKs from a bundle to install on a device

Where is the AAB file and how do you test it?

The notification after the build includes a locate link. In a standard project, release bundles are normally written under app/build/outputs/bundle/release/. Google's page does not document that path, so trust the locate link if yours is different.

Because a bundle cannot be installed on its own, test it one of two ways:

  • Upload it to an internal test and install from Google Play on a real phone. This also tests signing and versioning. See internal testing vs closed testing.
  • Use bundletool to build a set of APKs from the bundle and install them over USB, which is useful for fast checks.

How do you upload the AAB to Play Console?

  1. Open your appIn Play Console choose the app, then the testing track you want (internal, closed or production).
  2. Create a new releaseClick Create new release.
  3. Confirm app signingOn your first release you can use the Google-generated app signing key (the default) or provide your own.
  4. Upload the .aabDrag the file into the app bundles box and wait for processing.
  5. Add release notesWrite what is new in one or two sentences.
  6. Review the summaryFix any errors. Warnings do not block publishing, but read them.
  7. Roll outSave, then review and roll out the release.

If this is your first app, your next step is the closed test. Read how to get 12 testers and how to add testers in Play Console.

How do you fix common AAB upload errors?

Message or symptomLikely causeFix
Version code already usedYou reused a versionCodeIncrease versionCode and rebuild
Version code too highValue above 2100000000Use a smaller number
Signed with the wrong keyA different keystore than the one registered as your upload keyUse the original keystore, or request an upload key reset. See Play App Signing
Upload a bundle, not an APKYou uploaded an .apkBuild with Generate Signed App Bundle or bundleRelease
Bundle is not signed or debuggableA debug variant was builtBuild the release variant
Target API level warningYour targetSdk is below Google's current requirementRaise targetSdk to the level Play Console names
Bundle too largeCompressed download exceeds the limitUse Play Feature Delivery or Play Asset Delivery, remove unused resources
Part of a series: this article is one chapter of Google Play Closed Testing: The Complete Guide. Start there for the full roadmap from setup to production.

Sources

Frequently asked questions

Does Google Play still accept APK files?

Not for new apps. The Android Developers documentation says that since August 2021 new apps must be published with an Android App Bundle on Google Play. An APK is still useful for sharing a build directly with a device.

Where is the AAB file saved after I build it?

Android Studio shows a notification with a locate link when the build finishes. In a standard project the release bundle is normally under app/build/outputs/bundle/release/. Google's page does not state this path, so use the locate link if yours differs.

Can I install an AAB file on my phone?

Not directly. Google says an app bundle cannot be installed on a device on its own. Use bundletool to generate APKs from it, or upload it to an internal test and install from Google Play.

Which signing tool do I use for a bundle?

Android Studio signs it for you. If you sign manually, Google says to use jarsigner for bundles, because apksigner works only for APKs.

What is the largest bundle I can upload?

Google says the compressed APKs that must be downloaded to install your app (base plus configuration APKs) must total no more than 4 GB. New apps over 200 MB are supported through Play Feature Delivery or Play Asset Delivery.

Why does Play Console reject my version code?

Each upload needs a higher versionCode than any you have used. The highest value Google Play allows is 2100000000.