23

It's been so long since I develop a mobile app in react native, when I'm developing before, I usually generate a release apk and send it to my clients so that they can test it and have experienced it, but now when I build a release in react native, it returns a .aab instead of .apk, how can I send my application to the clients when I only get .aab format on my project?

1

7 Answers 7

33

It using for different android devices installation by google play store. that's why you can use apk build for manual installation.

You must use the below command for the testing build.

$ cd android
$ ./gradlew assembleRelease
3
  • Please edit your answer, as referred by Paul Freeman. its the correct command.
    – Kash
    Commented Mar 31, 2020 at 16:16
  • 1
    If you are on windows then omit the ./. It should be gradlew assembleRelease only. Commented May 10, 2020 at 17:20
  • 1
    The command from RN doc is ./gradlew bundleRelease (reactnative.dev/docs/signed-apk-android). Why and how is it different from ./gradlew assembleRelease ? I noticed 1 thing when trying to create universal apk files: only assembleRelease allowed me to generate .apk file(s) directly, whereas bundleRelease didn't create anything in /android/app/build/outputs/apk/release
    – Morris
    Commented Sep 19, 2021 at 19:48
7

As mentioned repeatedly in many places .aab file is efficient. But we need .apk for regular task (except PlayStore).

So:-

  1. Create signed output of Android project Link
  2. Use command $ npx react-native run-android for debugging.
  3. Finally $ npx react-native run-android --variant=release Link, to create release version, which is created at android/app/build/outputs/bundle/release/app.apk
  4. Go crazy
5

Just for the information. If you upload the AAB to Google Play instead of the APK, it will lead to smaller download sizes. AAB lets Google Play create different APKs to different devices, based on the device screen density, language, and CPU architecture. So, if you're able to create AAB's, use them over APK's.

5
cd android
./gradlew bundleRelease
1
  • 1
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value.
    – nima
    Commented Oct 30, 2022 at 7:34
0

The generated AAB can be found under

android/app/build/outputs/bundle/release/app-release.aab

, and is ready to be uploaded to Google Play

0

if you want to generate APK file instead of aab file using for Manual Testing then follow below steps.

 1. cd android
 2. ./gradlew clean
 3. ./gradlew assembleRelease

Thanks.

0

in the newer version

first, go to the Android folder and run the below command

./gradlew clean

this will clean the project by removing the build directory and all the files generated during previous builds

Now run the below command to generate a production-level aab file

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

this will create an aab file in android/app/build/outputs/bundle/release/app-release.aab

Note:- if the build fails try to delete drawable-* files in android/app/src/main/res/ folder

Not the answer you're looking for? Browse other questions tagged or ask your own question.