How to Generate an .aab File in a React Native Project for Google Play Console

How to Generate an .aab File in a React Native Project for Google Play Console
Photo by Emilio Garcia / Unsplash

When developing a React Native app and preparing it for release on the Google Play Console, it's essential to generate the correct file format. While APK files are commonly used, Google Play Console imposes a 100MB size limit on APKs. If your app exceeds this limit, you'll need to generate an Android App Bundle (.aab) instead. Here's a comprehensive guide on how to generate an .aab file for your React Native project.

Why Use .aab Instead of .apk?

  • Size Limitation: Google Play Console allows APK files up to 100MB. If your app exceeds this size, you must use an .aab file, which supports larger apps.
  • Optimized Delivery: .aab files enable Google Play's Dynamic Delivery, optimizing app delivery to users based on their device configuration.

Steps to Generate an .aab File

1. Open Your Terminal

First, open a terminal or command prompt.

2. Navigate to the Android Directory

Change your directory to your project's Android folder:

cd path/to/your/project/android

3. Run the Gradle Bundle Command

Execute the Gradle command to build the app bundle in release mode:

./gradlew bundleRelease

On Windows, use:

gradlew.bat bundleRelease

4. Locate the .aab File

After the build process completes, find the generated .aab file in the following directory:

path/to/your/project/android/app/build/outputs/bundle/release/app-release.aab

Updating Version Code and Version Name

Before generating the bundle, update the version code and version name in your project to ensure the new release is accepted by the Google Play Console.

1. Open build.gradle (App Module)

Navigate to android/app/build.gradle.

2. Update versionCode and versionName

In the defaultConfig block, increment the versionCode and update the versionName as needed:

android {
    ...
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 2
        versionName "1.1"
        ...
    }
}

Summary

To generate an .aab file for your React Native project:

  1. Open terminal and navigate to the android directory.
  2. Run the Gradle command:
  • On Unix-based systems: ./gradlew bundleRelease
  • On Windows: gradlew.bat bundleRelease
  1. Update versionCode and versionName in android/app/build.gradle if necessary.
  2. Locate the .aab file in android/app/build/outputs/bundle/release/.

Important Note

Remember, if your APK file exceeds 100MB, Google Play Console will not accept it. Instead, you must generate and upload an .aab file for your release. This not only allows for larger app sizes but also enables optimized app delivery through Google Play's Dynamic Delivery.

By following these steps, you can ensure your React Native app is correctly packaged and ready for distribution on the Google Play Console, regardless of its size.

Publishing to Google Play Store · React Native
Android requires that all apps be digitally signed with a certificate before they can be installed. In order to distribute your Android application via Google Play store it needs to be signed with a release key that then needs to be used for all future updates. Since 2017 it is possible for Google P…

Subscribe to Post, Code and Quiet Time.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe