diff --git a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index e91eac877f2d6e..f5accca2c82c7e 100644 --- a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -47,7 +47,6 @@ public List getPackages() { public void onCreate() { ReactFontManager.getInstance().addCustomFont(this, "Rubik", R.font.rubik); super.onCreate(); - SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 6f2338c7978ff9..2c8b5eea7e4b63 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -317,7 +317,7 @@ public List getPackages() { return new ArrayList<>(mPackages); } - private static void initializeSoLoaderIfNecessary(Context applicationContext) { + static void initializeSoLoaderIfNecessary(Context applicationContext) { // Call SoLoader.initialize here, this is required for apps that does not use exopackage and // does not use SoLoader for loading other native code except from the one used by React Native // This way we don't need to require others to have additional initialization code and to diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java index e58b8cc4550d4b..04b0d519521d6b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java @@ -5,10 +5,13 @@ package com.facebook.react; +import static com.facebook.react.ReactInstanceManager.initializeSoLoaderIfNecessary; import static com.facebook.react.modules.systeminfo.AndroidInfoHelpers.getFriendlyDeviceName; import android.app.Activity; import android.app.Application; +import android.content.Context; + import androidx.annotation.Nullable; import com.facebook.hermes.reactexecutor.HermesExecutorFactory; import com.facebook.infer.annotation.Assertions; @@ -254,6 +257,7 @@ public ReactInstanceManager build() { } // We use the name of the device and the app for debugging & metrics + //noinspection ConstantConditions String appName = mApplication.getPackageName(); String deviceName = getFriendlyDeviceName(); @@ -262,7 +266,7 @@ public ReactInstanceManager build() { mCurrentActivity, mDefaultHardwareBackBtnHandler, mJavaScriptExecutorFactory == null - ? getDefaultJSExecutorFactory(appName, deviceName) + ? getDefaultJSExecutorFactory(appName, deviceName, mApplication.getApplicationContext()) : mJavaScriptExecutorFactory, (mJSBundleLoader == null && mJSBundleAssetUrl != null) ? JSBundleLoader.createAssetLoader( @@ -284,9 +288,10 @@ public ReactInstanceManager build() { mCustomPackagerCommandHandlers); } - private JavaScriptExecutorFactory getDefaultJSExecutorFactory(String appName, String deviceName) { + private JavaScriptExecutorFactory getDefaultJSExecutorFactory(String appName, String deviceName, Context applicationContext) { try { // If JSC is included, use it as normal + initializeSoLoaderIfNecessary(applicationContext); SoLoader.loadLibrary("jscexecutor"); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) {