← Back to Chapters

Build APK & AAB in React Native

? Build APK & AAB in React Native

? Quick Overview

In React Native, Android apps are distributed as APK (Android Package) or AAB (Android App Bundle). APK is used for direct installation, while AAB is required for publishing on the Google Play Store.

? Key Concepts

  • APK – Installable Android application file
  • AAB – Optimized bundle uploaded to Play Store
  • Debug vs Release – Development vs production builds
  • Keystore – Used to sign release builds

? Syntax / Theory

React Native uses Gradle to generate Android builds. Release builds require signing configuration and are generated using Gradle wrapper commands.

? Code Example(s)

? View Code Example
// Navigate to android folder
cd android

// Clean previous builds
./gradlew clean

// Generate release APK
./gradlew assembleRelease
? View Code Example
// Generate Android App Bundle (AAB)
./gradlew bundleRelease

? Live Output / Explanation

? Generated Files

  • APK: android/app/build/outputs/apk/release/app-release.apk
  • AAB: android/app/build/outputs/bundle/release/app-release.aab

? Interactive Build Simulator

Click the buttons below to simulate the Gradle build process and see what happens in the terminal.

 
>_ Ready to build... waiting for command.

? Explanation

Think of AAB as a smart container. Google Play generates optimized APKs for different devices from the AAB automatically, reducing app size.

? Use Cases

  • APK for internal testing or direct sharing
  • AAB for publishing apps on Google Play Store
  • Release builds for production deployment

? Tips & Best Practices

  • Always use AAB for Play Store uploads
  • Keep your keystore file backed up securely
  • Use release builds for performance testing

? Try It Yourself

  • Create a release APK and install it on a physical device
  • Generate an AAB and upload it to Play Console (internal testing)
  • Compare APK size vs Play Store generated APK