react-native: java.lang.NoClassDefFoundError: com.facebook.react.jscexecutor.JSCExecutor

Description

49E6F3D0-F5C0-4816-925A-27CC2FFD6A0A

Version

0.71.1

Output of npx react-native info

info Fetching system and libraries information… System: OS: Windows 10 10.0.22000 CPU: (12) x64 Intel® Core™ i5-10400 CPU @ 2.90GHz Memory: 2.54 GB / 15.75 GB Binaries: Node: 16.15.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD npm: 7.22.0 - ~\AppData\Roaming\npm\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: AI-213.7172.25.2113.9123335 Visual Studio: Not Found Languages: Java: 11.0.13 - C:\Program Files\Android\Android Studio\jre\bin\javac.EXE npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: ^0.71.1 => 0.71.1 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Integration with Existing Apps,First jump AppletActivity no problem,Return to the previous activity,Second jump AppletActivity Errors

Snack, code example, screenshot, or link to a repository

https://gitee.com/yangguizhong/issue

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I had this issue and I solved it by calling .setJavaScriptExecutorFactory(HermesExecutorFactory()) on the object returned by ReactInstanceManager.builder(). This works if you’re using Hermes

@sanjeevyadavIT in your case, because you’ve overriding the ReactNativeHost, you can specify the HermesExecutorFactory() like this:

        object : ReactNativeHost(application) {
            ...
            override fun getJavaScriptExecutorFactory() = HermesExecutorFactory() // <-- override this and set.
        }

As mentioned, the problem is that you’re not creating a ReactInstanceManager correctly. That’s how the ReactNativeHost is doing it:

https://github.com/facebook/react-native/blob/6439baaca12f844b2192740bbaa5ee61edcba608/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java#L69-L84

You should either follow this pattern or use DefaultReactNativeHost as the template is doing which simplifies this setup for you

This worked for me also for those still facing issue on 0.71.2

reactInstanceManager = ReactInstanceManager.builder().setJavaScriptExecutorFactory(new HermesExecutorFactory()).setApplication(activity.getApplication())
                    .setCurrentActivity(activity).setBundleAssetName("index.android.bundle")
                    .setJSMainModulePath("index.android").addPackages(this.getPackages(_env.getValue()))
                    .setUseDeveloperSupport(BuildConfig.DEBUG).setInitialLifecycleState(LifecycleState.RESUMED).build();

This worked more me.

As mentioned, the problem is that you’re not creating a ReactInstanceManager correctly. That’s how the ReactNativeHost is doing it:

https://github.com/facebook/react-native/blob/6439baaca12f844b2192740bbaa5ee61edcba608/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java#L69-L84

You should either follow this pattern or use DefaultReactNativeHost as the template is doing which simplifies this setup for you

same problem

were you able to fix it?