Awesome Image Awesome Image

React Native November 15, 2023

React Native: How to Create .apk file for Android

Writen by qasimqadir89

comments 0

  1. Install the Expo CLI and EAS CLI: Make sure you have the Expo CLI and EAS CLI installed. You can install them using npm:bashCopy codenpm install -g expo-cli eas-cli
  2. Initialize EAS: If you haven’t initialized EAS for your Expo project yet, you can do so by running:bashCopy codeeas init Follow the prompts to set up EAS for your project.
  3. Configure the Build: Open your app.json file and make sure you have the appropriate configurations for the Android build. Ensure that the android field is configured correctly with the necessary settings.Example app.json snippet:jsonCopy code{ "expo": { "android": { "package": "com.example.myapp", "versionCode": 1 } } }
  4. Build the AAB: Run the following command to start the build process:bashCopy codeeas build -p android This command will build your project for Android, and if successful, it will generate an AAB file.
  5. Retrieve the Build Artifacts: Once the build is complete, EAS will provide you with a link to download the build artifacts. You can also find the link in the EAS Build dashboard.Example output:bashCopy codeBuild successfully started, it may take a few minutes to complete. You can monitor the build at https://expo.dev/accounts/your-account/builds/your-build-id Open the provided link in your web browser, and you should be able to download the generated AAB file from there.

That’s it! You have successfully generated an Android App Bundle (AAB) using eas build.

Now to convert an Android App Bundle (AAB) file to an APK file, you can use the bundletool provided by Google. The bundletool is a command-line tool that allows you to build APK sets from Android App Bundles. Here are the steps:


  1. Install Java: Ensure that you have Java installed on your machine. You can download and install OpenJDK or Oracle JDK.
  2. Download bundletool: You can download the bundletool JAR file from the official GitHub releases page: bundletool releases

Steps to Convert .AAB to .APK:

  1. Place AAB file and bundletool JAR in the Same Directory: Copy the AAB file you want to convert and the downloaded bundletool JAR file into the same directory.
  2. Open Terminal: Open your terminal or command prompt.
  3. Navigate to the Directory: Use the cd command to navigate to the directory where your AAB file and bundletool JAR are located.bashCopy codecd /path/to/directory
  4. Run bundletool to Generate APK Set: Use the following command to generate APK Set from the AAB file:bashCopy codejava -jar bundletool-all-<version>.jar build-apks --bundle=your-app.aab --output=your-app.apks Make sure to replace <version> with the version of the bundletool JAR file you downloaded, and replace your-app.aab with the actual name of your AAB file.
  5. Extract APKs from APK Set: Once the APK Set (your-app.apks) is generated, use the following command to extract the APKs:bashCopy codejava -jar bundletool-all-<version>.jar extract-apks --apks=your-app.apks --output-dir=output-directory Replace <version> with the version of the bundletool JAR file, and specify the output directory where you want to store the extracted APKs.
  6. Find the APKs: The extracted APKs will be available in the specified output directory. Look for files with the .apk extension.

Now you have successfully converted the AAB file to APK files using the bundletool. Note that this process creates multiple APKs optimized for different device configurations. You can choose the appropriate APK based on your requirements.

Tags :

Leave A Comment