diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java index 2715b01c75a87b..aebbcebb87159c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java @@ -69,7 +69,7 @@ public class ReactInstanceManagerBuilder { private @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder; private @Nullable SurfaceDelegateFactory mSurfaceDelegateFactory; private @Nullable DevLoadingViewManager mDevLoadingViewManager; - private JSEngineResolutionAlgorithm jsEngineResolutionAlgorithm = null; + private @Nullable JSEngineResolutionAlgorithm mJSEngineResolutionAlgorithm = null; /* package protected */ ReactInstanceManagerBuilder() {} @@ -126,9 +126,10 @@ public ReactInstanceManagerBuilder setJSBundleLoader(JSBundleLoader jsBundleLoad * Sets the JS Engine to load as either Hermes or JSC. If not set, the default is JSC with a * Hermes fallback. */ - private void setJSEngineResolutionAlgorithm( + public ReactInstanceManagerBuilder setJSEngineResolutionAlgorithm( @Nullable JSEngineResolutionAlgorithm jsEngineResolutionAlgorithm) { - this.jsEngineResolutionAlgorithm = jsEngineResolutionAlgorithm; + mJSEngineResolutionAlgorithm = jsEngineResolutionAlgorithm; + return this; } /** @@ -362,7 +363,7 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory( // if nothing is specified, use old loading method // else load the required engine - if (jsEngineResolutionAlgorithm == null) { + if (mJSEngineResolutionAlgorithm == null) { FLog.w( TAG, "You're not setting the JS Engine Resolution Algorithm. " @@ -379,7 +380,7 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory( HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } - } else if (jsEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) { + } else if (mJSEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java index 11880869d94349..02c5f834689d25 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java @@ -81,7 +81,8 @@ protected ReactInstanceManager createReactInstanceManager() { .setJSIModulesPackage(getJSIModulePackage()) .setInitialLifecycleState(LifecycleState.BEFORE_CREATE) .setReactPackageTurboModuleManagerDelegateBuilder( - getReactPackageTurboModuleManagerDelegateBuilder()); + getReactPackageTurboModuleManagerDelegateBuilder()) + .setJSEngineResolutionAlgorithm(getJSEngineResolutionAlgorithm()); for (ReactPackage reactPackage : getPackages()) { builder.addPackage(reactPackage);