How to build .aab bundle instead .apk file with react native EXPO locally?

504 Views Asked by At

When I make a local build of an app created using EXPO react native, I get an .apk file instead of .aab

  1. For testing app build I am using expo template with expo router
npx create-expo-app@latest --template tabs@50
  1. Then I do prebuild
npx expo prebuild
  1. I'm following these instructions
    Production builds locally
    https://docs.expo.dev/deploy/build-project/#production-builds-locally
    Publishing to Google Play Store
    https://reactnative.dev/docs/signed-apk-android

  2. I'm generating a key with keytool

  3. I'm making changes to the android/gradle.properties file

  4. I'm making changes in the android/app/build.gradle adding signing config

  5. And finally I am using this command

npx expo run:android --variant release

After all this I get app-release.apk file in this folder "\android\app\build\outputs\apk\release"

But how I can get .aab bundle file?

3

There are 3 best solutions below

1
Aldarion On

check if your eas.json have

"android":{
                        "buildType": "apk"
                    },

under the channel you are trying to get your build from.

2
Abhi On

Have you tried ?

First go into your project dir in terminal.

  1. npm install -g eas-cli (to install eas in windows)
  2. Set-ExecutionPolicy RemoteSigned (to change permission of eas issue in terminal)
  3. eas build (to build aab file) eas build -p android --profile preview (to build apk file)
1
Drago On

One way of doing this is by running:

cd ./android
./gradlew bundleRelease

This will create app-release.aab in android/app/build/outputs/bundle/release directory.

Another way is by running:

npx react-native build-android --mode=release

even though in this documentation, it clearly states that you should use:

npx expo run:android --variant release