How to Make a Production Build in Expo for Android App Bundle (AAB) - abhiram-shaji/Langroove GitHub Wiki

Welcome to this guide on creating an AAB (Android App Bundle) from your Expo app. App Bundles are the recommended format for uploading to Google Play, allowing Google to optimize your app for different devices. There are two main ways to achieve this:

  1. Using Expo’s Classic Build Service (Deprecated)
  2. Using EAS Build (Expo Application Services) (Recommended)

We'll focus primarily on EAS Build, which is more modern and reliable, but will also include instructions for the classic method for reference.


1. Using EAS Build (Recommended)

Expo's EAS Build service offers a flexible and powerful build process that generates optimized builds for production, including AABs for Android.

Step 1: Install EAS CLI

First, install the EAS CLI globally on your computer.

npm install -g eas-cli

Step 2: Configure Your Project for EAS

Initialize EAS configuration by running the following command in your project directory. This will generate an eas.json file with build configuration options.

eas build:configure

An example eas.json configuration for an Android App Bundle (AAB) might look like this:

{
  "build": {
    "production": {
      "android": {
        "buildType": "app-bundle"
      }
    }
  }
}

Step 3: Set Up a Keystore

For publishing on Google Play, your AAB must be signed with a keystore. You can generate a keystore automatically during the build process, or you can use an existing one. To manage and view your credentials, use:

eas credentials

Step 4: Build the AAB

To start the build, use the following command:

eas build --platform android --profile production

Monitor the build process in your terminal. Once completed, a download link for the AAB will be provided.

Step 5: Download and Test the AAB

After the build finishes, download the AAB file from the provided link. You can upload this file directly to Google Play Console for distribution.


2. Using Expo’s Classic Build Service (Deprecated)

If you're not yet using EAS and need to build with Expo’s classic system, here’s how to generate an APK or AAB.

Step 1: Classic Expo Workflow

Ensure you're using the Expo-managed workflow. For bare workflow projects, use EAS Build.

Step 2: Build the AAB

Run the following command to start a classic build for Android:

expo build:android

Expo will prompt you to set up an Android keystore if needed.

Step 3: Choose AAB or APK

When prompted, select the App Bundle (AAB) option:

? Would you like to build an APK or an Android App Bundle (AAB)? (Use arrow keys)
❯ App Bundle (AAB)

Step 4: Download and Upload

Once the build completes, download the AAB file from the provided link and upload it to the Google Play Console.


Additional Notes

  • EAS Project Configuration: In app.json, ensure Android-specific settings, such as the package name, permissions, and version code, are correct:

    {
      "expo": {
        "android": {
          "package": "com.yourappname",
          "permissions": ["CAMERA", "LOCATION"]
        }
      }
    }
    
  • Credential Management: You can manage your Android keystore with:

    eas credentials
    

For more detailed information on using EAS and Expo for production builds, visit the Expo Documentation.

By following these steps, you'll be ready to distribute your app as an AAB through the Google Play Console, optimized for Android devices.