John Jerald De Chavez

Build Expo Application Locally

Creating a production app for local installation on your phone without publishing to an app store involves different processes for Android. This is often called "sideloading" and requires you to generate a signed build of your app

Here is a comprehensive guide on how to create a production app for local installation on your phone.

Build Android

The process for Android involves generating a keystore, configuring your project, and then building and installing a signed .apk or .aab file.

Generate a Signing Key

You need a private signing key to securely sign your app. This can be created using the keytool utility, which is part of the Java Development Kit (JDK).

Open your terminal and run the following command. Remember to replace the placeholders with your own information.

keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

This command will prompt you to create a password for the keystore and the key alias. Remember these passwords, as you will need them later.

Place the Keystore

Copy the newly created my-release-key.leystore file and place it in the android/app directory of your React Native project.

Configure Gradle

You need to tell Gradle where to find your keystore.

  MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
  MYAPP_RELEASE_KEY_ALIAS=my-key-alias
  MYAPP_RELEASE_STORE_PASSWORD=*****
  MYAPP_RELEASE_KEY_PASSWORD=*****
...
android {
  defaultConfig { ... } 
  signingConfigs {
    release {
      if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
        storeFile file(MYAPP_RELEASE_STORE_FILE)
        storePassword MYAPP_RELEASE_STORE_PASSWORD
        keyAlias MYAPP_RELEASE_KEY_ALIAS
        keyPassword MYAPP_RELEASE_KEY_PASSWORD
      }
    }
  }
  buildTypes {
    release {
      ...
      signingConfig signingConfigs.release
    }
  } 
}

Generate the Release APK

Navigate to the android directory in your terminal and run the following command to build the signed release APK.

cd android && ./gradlew assembleRelease

Once the process is complete, you will find the app-release.apk file in the android/app/build/outputs/apk/release/ directory.

Install the APK on Your Phone

To install the app on your phone, you need to enable Developer Options and USB Debugging on your Android device. Then connect your phone to your computer via USB and use the follwing command.

adb install android/app/build/outputs/apk/release/app-release.apk

Now you can use your application on your Android device.