# Fixing React-Native android release build

After devoting several months to meticulous research and development, your app is finally ready for release. Filled with boundless excitement and a sense of achievement, you look forward to introducing your million-dollar app to the world. You then follow every step mentioned in [React-Native’s official guide](https://reactnative.dev/docs/signed-apk-android) to generate a production-ready `.apk` file for testing your app before publishing it to the Google Play Store.

Subsequently, you execute the following command in a terminal to compile and generate a production build `.apk` file; the generated file will be located under `android/app/build/outputs/apk/release/app-release.apk`.

```bash
cd android
./gradlew assembleRelease
```

After generating the `.apk` file, you install it on your Android device, and as soon as you open the app, it crashes.

You don’t know what went wrong; you start rechecking to see if you missed any steps mentioned in the React-Native documentation; you start searching for solutions on StackOverflow and Github and try out all the random solutions you discovered. You feel frustrated, stressed out, and filled with self-doubt. Imposter syndrome kicks in, and you regret choosing React-Native over other mobile development frameworks.

---

**TL;DR:** I had a similar feeling after going through a lot of answers and comments on StackOverflow and GitHub issues. Here are the steps I followed to find and fix the issues with the release build.

# **Using Logcat CLI to determine the issue**

Connect your device to your machine (ensure USB debugging is **ON**) and run the following command on your terminal.

```bash
adb logcat '*:E'
```

Find out more about **Logcat CLI syntax** [here](https://developer.android.com/studio/command-line/logcat).

After running the logcat tool to log system logs, I had two issues that were causing the application to crash.

### **1\. couldn’t find DSO to load:** [**libjsexecutor.so**](http://libjsexecutor.so)

![java.lang.UnsatisfiedLinkError: couldn’t find DSO to load: libjsexecutor.so](https://miro.medium.com/max/1400/1*kWZI7ICdeeuONY0AaZd-8A.png align="center")

I solved [libjsexecutor.so](http://libjsexecutor.so) error by adding `enableVmCleanup: false` in `build.gradle` file inside `project.ext.react` array as mentioned in the GitHub comment [here](https://github.com/facebook/react-native/issues/25537#issuecomment-1104619909).

```java
project.ext.react = [
    enableHermes: true,     // clean and rebuild if changing
    enableVmCleanup: false, //this
]
```

### 2\. **java.lang.RuntimeException: Unable to load script.**

![java.lang.RuntimeException: Unable to load script. Make sure you’re either running Metro (run ‘npx react-native start’) or that your bundle ‘index.android.bundle’ is packaged correctly for release.](https://miro.medium.com/max/1400/1*ACDTvBaEPpki9A8-3zUuyw.png align="left")

To solve this issue follow the steps below

* Remove [`index.android`](http://index.android)`.bundle` from `android/app/src/main/assets` if the file already exists or just run the following command (ensure you’re on your project’s root directory).
    

```bash
rm android/app/src/main/assets/index.android.bundle
```

* For generating your android bundle run the command given below, this will generate [`index.android`](http://index.android)`.bundle` file inside `android/app/src/main/assets`
    

```bash
npx react-native bundle \
--platform android \
--dev false \
--entry-file index.js \
--bundle-output android/app/src/main/assets/index.android.bundle
```

* Now run the following command to generate a release build
    

```bash
cd android
./gradlew clean
./gradlew assembleRelease
```

Hopefully, this will fix your app's crashing problem, and your app should be ready for deployment.

*Feel free to provide any feedback and improvements, happy coding…*
