react-nativebuildwebviewexpodependencies

React Native Expo - RNCWebView could not be found (development build)


I'm using React Native Expo and I need to use react-native-webview for my app. WebView works fine when I use Expo Go but if I switch in development build I get these errors

ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNCWebView' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called., js engine: hermes

I've tried everything I found in github like using [email protected] it does not work, while I can't use react-native link because Expo does not support this. What I found about it is that Expo Autolink mess something and I dunno how to solve it. Someone can help me?


Solution

  • For development build you need to create apk first to do the testing, type below command to build the apk, install it on the testing device, then you can run it on development build, it will not work if you didn't install the apk

    eas build --profile development --platform android

    Note: you need to create new build if you add new library

    Reference: https://docs.expo.dev/develop/development-builds/create-a-build/