skip to Main Content

I’m a new learner on this platform.
I code a simple react native app using expo. But I want to build a .apk file.
I tried this command:

expo build:android

Then I sign up an expo account. After completing the building process it shows the download button.
Just like the following picture: enter image description here But its not apk file. It is .aab file.
So, I want to build an actual apk file.
How can I do that?

4

Answers


  1. From expo documentation :
    When building for android you can choose to build APK (expo build:android -t apk) or Android App Bundle (expo build:android -t app-bundle).

    Login or Signup to reply.
  2. By default Expo, CLI builds the app into a .aab file format. this format is better for Google Play Store as it will be optimized for every device CPU architecture which results in a smaller app size.

    In case you want to test for your device or emulator, run:
    expo build:android -t apk

    Login or Signup to reply.
  3. Update for new users:

    Run the following:

    npm install -g eas-cli

    eas build -p android https://docs.expo.dev/build/setup/

    expo build:android will be discontinued on January 4, 2023

    Login or Signup to reply.
  4. to build a apk out of the file first you need to do some changes to your eas.json file.

    By default, EAS Build produces Android App Bundle, you can change it by:

    • setting buildType to apk
    • setting developmentClient to true
    • setting gradleCommand to :app:assembleRelease, :app:assembleDebug or any othergradle command that produces APK

    after changing the config you can run eas build -p android --profile preview to build the application

    you can read more about this in docs
    https://docs.expo.dev/build-reference/apk/

    and here’s a sample config i used for a basic project to build ( also you can find on docs )

    {
      "cli": {
        "version": ">= 0.52.0"
      },
      "build": {
        "preview": {
          "android": {
            "buildType": "apk"
          }
        },
        "preview2": {
          "android": {
            "gradleCommand": ":app:assembleRelease"
          }
        },
        "preview3": {
          "developmentClient": true
        },
        "production": {}
      }
    }
    

    also alternatively another possible way would be to get the bundle ( .aab ) file and convert it to apk using a too like bundletool. and you can find the apk ( universal.apk ) inside app.apks

    bundletool build-apks --bundle=bundle.aab --output=app.apks --mode=universal 
    

    https://github.com/google/bundletool

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search