How to Generate an .aab File in a React Native Project for Google Play Console
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:
- Open terminal and navigate to the
android
directory. - Run the Gradle command:
- On Unix-based systems:
./gradlew bundleRelease
- On Windows:
gradlew.bat bundleRelease
- Update
versionCode
andversionName
inandroid/app/build.gradle
if necessary. - 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.
![](https://reactnative.dev/img/logo-og.png)