skip to Main Content

I started migrating my react-native project from 0.73.0 to 0.76.1. I’ve had to keep the new architecture to false since some of the packages I use don’t seem to support it.

The project works fine in iOS but when I run in it Android I get the exception below from LogCat in the virtual device.

java.lang.UnsatisfiedLinkError: dlopen failed: library "libhermes_executor.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1081) at java.lang.Runtime.loadLibrary0(Runtime.java:1003) at java.lang.System.loadLibrary(System.java:1765) at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:24)
at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:52) at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:812) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:27)
at com.facebook.hermes.reactexecutor.HermesExecutor.
<clinit>(HermesExecutor.java:20) at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:407) at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:349) at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:87)
  at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:57) at com.facebook.react.ReactDelegate.loadApp(ReactDelegate.java:301) at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:137) at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:132)
  at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:47) at android.app.Activity.performCreate(Activity.java:9002) at android.app.Activity.performCreate(Activity.java:8980) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1526)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4030) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4235) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:112) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:174)
  at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:109) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2636)
  at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8705) at java.lang.reflect.Method.invoke(Native
  Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)

My android/build.gradle is

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "35.0.0"
        minSdkVersion = 24
        compileSdkVersion = 35
        targetSdkVersion = 34

        ndkVersion = "26.1.10909125"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("com.google.gms:google-services:4.4.0")
    }
}

The only reference to a soloader I can see in the native java code comes from the MainApplication.java

import android.app.Application;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
      new DefaultReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
          return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          return packages;
        }

        @Override
        protected String getJSMainModuleName() {
          return "index";
        }

        @Override
        protected boolean isNewArchEnabled() {
          return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
        }

        @Override
        protected Boolean isHermesEnabled() {
          return BuildConfig.IS_HERMES_ENABLED;
        }
      };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
      // If you opted-in for the New Architecture, we load the native entry point for this app.
      DefaultNewArchitectureEntryPoint.load();
    }
    // ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  }
}

I’m hoping is something really silly due to lack of knowledge with native Android dev.

Thanks in advance for any help

2

Answers


  1. Hi Brother Did you read official document of existing app integration

    apply plugin: "com.android.application"
    +apply plugin: "com.facebook.react"
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        // Other dependencies here
    +   // Note: we intentionally don't specify the version number here as RNGP will take care of it.
    +   // If you don't use the RNGP, you'll have to specify version manually.
    +   implementation("com.facebook.react:react-android")
    +   implementation("com.facebook.react:hermes-android") 
    }
    
    +react {
    +   // Needed to enable Autolinking - https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
    +   autolinkLibrariesWithApp()
    +}
    

    You have to add this line in your project ProjectRoot/android/app/build.gradle

    *implementation("com.facebook.react:hermes-android")* 
    

    This will work, Also please check this Community Template by React Team

    https://github.com/react-native-community/template/blob/0.76-stable/template/android/app/build.gradle

    Login or Signup to reply.
  2. I have also faced the same issue, re-verifying the changes I found out that I had forgot to change one of the line (at createReactActivityDelegate) in MainActivity.kt file.

    Please check if yours is also the same.

    package com.dom.edeka
    
    import android.os.Bundle
    import com.facebook.react.ReactActivity
    import com.facebook.react.ReactActivityDelegate
    import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
    import com.facebook.react.defaults.DefaultReactActivityDelegate
    
    class MainActivity : ReactActivity() {
    
        /**
         * Returns the name of the main component registered from JavaScript. This is used to schedule
         * rendering of the component.
         */
        override fun getMainComponentName(): String {
            return "EDEKA"
        }
    
        /**
         * Returns the instance of the [ReactActivityDelegate]. Here, the RootView is created, and
         * you can specify the renderer you wish to use (Fabric or the older renderer).
         */
        override fun createReactActivityDelegate(): ReactActivityDelegate {
            return DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
        }
    
        override fun onCreate(savedInstanceState: Bundle?) {
            // ToDo: This code is written to check the screen-related crash that appeared in Android 13 and on some specific devices
            super.onCreate(null)
        }
    }
    
    

    Hope it solves your problem!!

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