How to Generate a React Native Release Build APK for Android

I.Setting up the development environment

https://reactnative.dev/docs/environment-setup

Install environment 

brew install node

brew install watchman

brew install yarn

Java Development Kit

brew install --cask adoptopenjdk/openjdk/adoptopenjdk8

Android development environment

1. Install Android Studio

Download and install Android Studio. While on Android Studio installation wizard, make sure the boxes next to all of the following items are checked:

  • Android SDK
  • Android SDK Platform
  • Android Virtual Device

2. Install the Android SDK

open Android Studio -> Android Studio "Preferences" dialog, under Appearance & Behavior → System Settings → Android SDK.

Install SDK platforms and save Android SDK Location

II.Build apk application.

https://developer.android.com/studio/publish/app-signing

Generate an upload key and keystore

Generate a keystore and alway keep this keystore for update application

If you don't already have an upload key, which is useful when configuring Play App Signing, you can generate one using Android Studio as follows:

  1. In the menu bar, click Build > Generate Signed Bundle/APK.
  2. In the Generate Signed Bundle or APK dialog, select Android App Bundle or APK and click Next.
  3. Below the field for Key store path, click Create new.
  4. On the New Key Store window, provide the following information for your keystore and key, as shown in figure 2.
  5. Keystore
    1. Key store path: Select the location where your keystore should be created.
    2. Password: Create and confirm a secure password for your keystore.
  6. Key
    1. Alias: Enter an identifying name for your key.
    2. Password: Create and confirm a secure password for your key. This should be different from the password you chose for your keystore.
    3. Validity (years): Set the length of time in years that your key will be valid. Your key should be valid for at least 25 years, so you can sign app updates with the same key through the lifespan of your app.
    4. Certificate: Enter some information about yourself for your certificate. This information is not displayed in your app, but is included in your certificate as part of the APK.
  7. Once you complete the form, click OK.
Figure 2. Create a new upload key and keystore in Android Studio.

Sign your app with your upload key

  1. Check out your source code from git. 
  2. Update version code and version name if update app to store.

Open file gradle from rootProject -> android -> app -> build.gradle

  1. Update keystore to build if need

Copy keystore generate to publish application to rootProject -> android folder; 

Set password for your keystore in rootProject -> android -> gradle.properties 

  1. Open terminal from root project folder your_project % 
  2. Setup environment Android Home (Android SDK location) and Java Home (Java SDK location) by command line:

export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"

export ANDROID_HOME=$HOME/Library/Android/sdk

export PATH=$PATH:$ANDROID_HOME/emulator

export PATH=$PATH:$ANDROID_HOME/tools

export PATH=$PATH:$ANDROID_HOME/tools/bin

export PATH=$PATH:$ANDROID_HOME/platform-tools

  1. Install react-native library:  yarn install 
  2. Build android application to publish 

cd android 

./gradlew bundleProductRelease

  1. Open folder to get .aab file to publish

.open app/build/output/bundle/productRelease

II.Upload your application to Google play.

Upload your app to Google Play

Prepare & roll out release of your app


This free site is ad-supported. Learn more