Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found #2847

Closed
lynajiang opened this issue Apr 4, 2024 · 35 comments
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@lynajiang
Copy link

Description

In process of installing @gorhom/bottom-sheet package, I was installing the gesture-handler package. I followed all the steps of installation which included adding import statements (import 'react-native-gesture-handler') to both App.tsx and index.js. In app.tsx, GestureHandlerRootView wraps the contents. The code breaks even when I comment out the @gorhom/bottom-sheet package and components.

Of course in debugging this whole debacle,

  1. Deleted the pod files, podfile.lock, and node_modules folder.
  2. Pod install and npm install in respective folders
  3. Clean build folder in xcode
  4. Deleted DerivedData
  5. Rebuild

Since this is very similar to #2749, I've tried all the solutions there. Nothing has worked.

Steps to reproduce

  1. Install @gorhom/bottom-sheet, react-native-reanimated, react-native-gesture-handler
  2. Finish installation steps for all three packages

Snack or a link to a repository

https://github.com/lynajiang/Project-Lemon-Issue-Code.git

Gesture Handler version

2.16.0

React Native version

0.73.6

Platforms

iOS

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

None

Device

Real device

Device model

iPhone 14 Pro iOS 17.4

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: iOS This issue is specific to iOS labels Apr 4, 2024
@m-bert
Copy link
Contributor

m-bert commented Apr 4, 2024

Hi @lynajiang! I've just build your app on both, iOS simulator and real device and everything works fine (though there was an error that useMemo was not imported). Are you sure you've properly cleaned your environment? Make sure to delete pods and node_modules

@lynajiang
Copy link
Author

Yes. I am sure I properly cleaned the environment. I uninstalled and reinstalled a couple of times. If I were to comment out "import 'react-native-gesture-handler';" in both App.tsx and index.js as well as import { GestureHandlerRootView } from 'react-native-gesture-handler'; in App.tsx (and commenting out GestureHandlerRootView). I would not get any errors. This of course would make the bottomsheet component error since the Gesture Handler module is not sufficiently installed.

@m-bert
Copy link
Contributor

m-bert commented Apr 5, 2024

In that case could you provide more information about this error? Like stack trace or full error message?

@m-bert
Copy link
Contributor

m-bert commented Apr 5, 2024

Also, have you encountered this issue before? Did it happen after upgrading gesture handler (or react native) version?

@lynajiang
Copy link
Author

The full error message is:
ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","LogBox","Timing","AppState","SourceCode","BlobModule","WebSocketModule","SettingsManager","DevSettings","RedBox","Networking","Appearance","DevLoadingView","UIManager","DeviceInfo"],"TurboModules":[],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","BugReporting","HeadlessJsTaskSupport","RNGestureHandlerModule"]}, js engine: hermes
LOG Running "Lemon" with {"rootTag":1,"initialProps":{}}
ERROR Invariant Violation: "Lemon" 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

And I have never used react-gesture-handler before. I had just installed the most up-to-date version of both react-native and react-gesture-handler packages.

@lynajiang
Copy link
Author

I also have pushed a cleaner version of the code.

@anucreative

This comment was marked as outdated.

@lynajiang
Copy link
Author

@anucreative Thank you! After downgrading gesture-handler to 2.15.0, it worked.

@m-bert m-bert reopened this Apr 8, 2024
@m-bert
Copy link
Contributor

m-bert commented Apr 8, 2024

Though downgrading may help, it is not a solution that we recommend. I will keep this issue open until we find out what causes that problem.

@naitik-erpbuddies
Copy link

I am also facing the same issue

@patricktelnoni
Copy link

I am currently facing the same issue here. Is this beacuse dependency problem during instalation, because i use react 18 on my project.. Here is the log result upon installing rect-native-gesture-handler. Please note that after i user yard, the package installed in my node_module project yet i get the ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found.

Here is the error upon installing react-native-gesture-handler
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: AwesomeProject@0.0.1
npm ERR! Found: @types/react@18.3.0
npm ERR! node_modules/@types/react
npm ERR! dev @types/react@"^18.2.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @types/react@"^16.9.19" from native-base@3.3.1
npm ERR! node_modules/native-base
npm ERR! native-base@"3.3.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-debug-0.log
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: AwesomeProject@0.0.1
npm ERR! Found: @types/react@18.3.0
npm ERR! node_modules/@types/react
npm ERR! dev @types/react@"^18.2.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @types/react@"^16.9.19" from native-base@3.3.1
npm ERR! node_modules/native-base
npm ERR! native-base@"3.3.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-debug-0.log

@C2418M31
Copy link

C2418M31 commented May 19, 2024

I experience the same, tried downloading to 2.15.0 from 2.16.0. It is working when running npm start, but when I tried to convert it to aar and upload to a native android. this error shows up. I hope someone can help me on this.

Gesture Handler version
2.16.0

React Native version
0.74.1

Platform
Android

Type
AAR

Unhandled SoftException com.facebook.react.bridge.ReactNoCrashSoftException: Tried to access onWindowFocusChange while context is not ready at com.facebook.react.runtime.ReactHostImpl.onWindowFocusChange(ReactHostImpl.java:674) at com.facebook.react.ReactDelegate.onWindowFocusChanged(ReactDelegate.java:194) at com.facebook.react.ReactActivityDelegate.onWindowFocusChanged(ReactActivityDelegate.java:175) at com.facebook.react.ReactActivity.onWindowFocusChanged(ReactActivity.java:128) at androidx.appcompat.view.WindowCallbackWrapper.onWindowFocusChanged(WindowCallbackWrapper.java:125) at com.android.internal.policy.DecorView.onWindowFocusChanged(DecorView.java:1788) at android.view.View.dispatchWindowFocusChanged(View.java:15933) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1509) at android.view.ViewRootImpl.dispatchFocusEvent(ViewRootImpl.java:4059) at android.view.ViewRootImpl.handleWindowFocusChanged(ViewRootImpl.java:3963) at android.view.ViewRootImpl.-$$Nest$mhandleWindowFocusChanged(Unknown Source:0) at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:5954) at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:5862) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: true. TurboModule interop: true. Modules loaded: {"NativeModules":[],"TurboModules":["PlatformConstants","DeviceInfo","DeviceEventManager","BlobModule","NativeAnimatedModule"],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","HeadlessJsTaskSupport","NativeReactNativeFeatureFlagsCxx","RNGestureHandlerModule"]}

@themikan
Copy link

I experience the same, tried downloading to 2.15.0 from 2.16.0. It is working when running npm start, but when I tried to convert it to aar and upload to a native android. this error shows up. I hope someone can help me on this.我也有同样的经历,尝试从2.16.0下载到2.15.0。它在运行 npm start 时工作,但是当我尝试将其转换为 aar 并上传到本机 android 时。出现此错误。我希望有人能在这方面帮助我。

Gesture Handler version 手势处理程序版本 2.16.0

React Native version 反应本机版本 0.74.1

Platform 平台 Android  安卓

Type 类型 AAR

Unhandled SoftException com.facebook.react.bridge.ReactNoCrashSoftException: Tried to access onWindowFocusChange while context is not ready at com.facebook.react.runtime.ReactHostImpl.onWindowFocusChange(ReactHostImpl.java:674) at com.facebook.react.ReactDelegate.onWindowFocusChanged(ReactDelegate.java:194) at com.facebook.react.ReactActivityDelegate.onWindowFocusChanged(ReactActivityDelegate.java:175) at com.facebook.react.ReactActivity.onWindowFocusChanged(ReactActivity.java:128) at androidx.appcompat.view.WindowCallbackWrapper.onWindowFocusChanged(WindowCallbackWrapper.java:125) at com.android.internal.policy.DecorView.onWindowFocusChanged(DecorView.java:1788) at android.view.View.dispatchWindowFocusChanged(View.java:15933) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1509) at android.view.ViewRootImpl.dispatchFocusEvent(ViewRootImpl.java:4059) at android.view.ViewRootImpl.handleWindowFocusChanged(ViewRootImpl.java:3963) at android.view.ViewRootImpl.-$$Nest$mhandleWindowFocusChanged(Unknown Source:0) at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:5954) at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:5862) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: true. TurboModule interop: true. Modules loaded: {"NativeModules":[],"TurboModules":["PlatformConstants","DeviceInfo","DeviceEventManager","BlobModule","NativeAnimatedModule"],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","HeadlessJsTaskSupport","NativeReactNativeFeatureFlagsCxx","RNGestureHandlerModule"]}

I have same problem

@YiguiDing
Copy link

same error

1 similar comment
@MrNapcae
Copy link

MrNapcae commented Jun 2, 2024

same error

@raquelnishimoto
Copy link

Note that this answer is aimed at ios.
There is no need to downgrade the package. Try installing the pod
cd ios && npx pod deintegrate && npx pod install && cd ..

Then, go to Xcode and clean the project:
Product -> Clean build folder
Finally, in Xcode build and run the project by clicking the play button (arrow forward).

@Ratna99
Copy link

Ratna99 commented Jun 27, 2024

For me, I had nx mono repo. And I have installed react-native-gesture-handler in my main package.json file (I was not using it directly but other package:react-navigation was using it). So, react-native-gesture-handler was missing in package.json of my mobile app directory. So, I added "react-native-gesture-handler": "*" in package.json inside my mobile directory, pod install in ios and then did a build run-ios. Then finally it worked.

@Anusha-mathur
Copy link

Anusha-mathur commented Jul 17, 2024

same error, If anyone know how to fix this please help.
this is happening in android

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: true. TurboModule interop: true. Modules loaded: {"NativeModules":[],"TurboModules":["PlatformConstants","LogBox","SourceCode","AppState","BlobModule","WebSocketModule","DevSettings","DevToolsSettingsManager","Networking","Appearance","DevLoadingView","DeviceInfo","ImageLoader","SoundManager","IntentAndroid","DeviceEventManager","NativeAnimatedModule","I18nManager"],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","HeadlessJsTaskSupport","LinkingManager","NativeReactNativeFeatureFlagsCxx","RNCSafeAreaContext","ReanimatedModule","RNGestureHandlerModule"]}
{"rootTag":11,"initialProps":{},"fabric":true}

@m-bert m-bert added the Platform: Android This issue is specific to Android label Aug 7, 2024
@vedantb2
Copy link

vedantb2 commented Aug 11, 2024

I'm also having this issue after building the APK for my app, and react-native-gesture-handler is the cause of it

@m-bert
Copy link
Contributor

m-bert commented Aug 16, 2024

Hi @lynajiang! Do you still experience this issue? If so, could you attach node_modules to reproduction? We would like to take a closer look into them

@m-bert
Copy link
Contributor

m-bert commented Aug 16, 2024

Also, to all who are currently seeing this issue. If it happens after upgrading react-native version, did you use React Native Upgrade Helper?

@ghostgarrix
Copy link

ghostgarrix commented Aug 19, 2024

@m-bert Yes, happened to me after Rn upgrade from 0.74.2 to 0.75.1 (latest) using the RN upgrade helper. App is building successfully but unit tests fail with a similar error: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found.

@jmazier-j2d
Copy link

Same here, upgrading from.... RN 0.66 to 0.74 (don't judge me !) and mostly following the upgrade helper. Can provide more info if needed.

@Olekssi56
Copy link

@anucreative Thank you! After downgrading gesture-handler to 2.15.0, it worked.
Hey, @lynajiang
Please show your jest.config.ts file.

@jmazier-j2d
Copy link

Any update here ? I'm still struggling with this issue (only on android) and it's just driving me crazy has it's preventing from releasing a huge update :(

I've even tried to remove all reference to RNGestureHandler but somehow, the error sticks... even after clearing all caches...

@IMSBuSu
Copy link

IMSBuSu commented Sep 18, 2024

I experience the same, tried downloading to 2.15.0 from 2.16.0. It is working when running npm start, but when I tried to convert it to aar and upload to a native android. this error shows up. I hope someone can help me on this.我也有同样的经历,尝试从2.16.0下载到2.15.0。它在运行 npm start 时工作,但是当我尝试将其转换为 aar 并上传到本机 android 时。出现此错误。我希望有人能在这方面帮助我。
Gesture Handler version 手势处理程序版本 2.16.0
React Native version 反应本机版本 0.74.1
Platform 平台 Android  安卓
Type 类型 AAR
Unhandled SoftException com.facebook.react.bridge.ReactNoCrashSoftException: Tried to access onWindowFocusChange while context is not ready at com.facebook.react.runtime.ReactHostImpl.onWindowFocusChange(ReactHostImpl.java:674) at com.facebook.react.ReactDelegate.onWindowFocusChanged(ReactDelegate.java:194) at com.facebook.react.ReactActivityDelegate.onWindowFocusChanged(ReactActivityDelegate.java:175) at com.facebook.react.ReactActivity.onWindowFocusChanged(ReactActivity.java:128) at androidx.appcompat.view.WindowCallbackWrapper.onWindowFocusChanged(WindowCallbackWrapper.java:125) at com.android.internal.policy.DecorView.onWindowFocusChanged(DecorView.java:1788) at android.view.View.dispatchWindowFocusChanged(View.java:15933) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1509) at android.view.ViewRootImpl.dispatchFocusEvent(ViewRootImpl.java:4059) at android.view.ViewRootImpl.handleWindowFocusChanged(ViewRootImpl.java:3963) at android.view.ViewRootImpl.-$$Nest$mhandleWindowFocusChanged(Unknown Source:0) at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:5954) at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:5862) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: true. TurboModule interop: true. Modules loaded: {"NativeModules":[],"TurboModules":["PlatformConstants","DeviceInfo","DeviceEventManager","BlobModule","NativeAnimatedModule"],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","HeadlessJsTaskSupport","NativeReactNativeFeatureFlagsCxx","RNGestureHandlerModule"]}

I have same problem

do you find any way ? my whatsapp +91 9213120419

@darkmoor24
Copy link

I'm new posting comments on github, I don't know if theres any kind of rule to refer a link.. but I solved this error based on this issue resolution

#2749

@m-bert
Copy link
Contributor

m-bert commented Oct 10, 2024

One more question, please look at this repro and tell me whether you can see this error or not.

To run it simply:

  1. Run yarn command in root
  2. Run bundle install && bundle exec pod install in ios directory

For Fabric, change newArchEnabled flag in gradle.properties in android directory:

-newArchEnabled=false
+newArchEnabled=true

And for ios set RCT_NEW_ARCH_ENABLED flag to 1:

RCT_NEW_ARCH_ENABLED=1 bundle install && bundle exec pod install

Please tell me if you see this error in my reproduction.

@j-piasecki j-piasecki added the Close when stale The issue will be closed automatically if it remains inactive label Oct 15, 2024
@petertoth-dev
Copy link

@m-bert still cannot fix this issue and we are totally stuck installing a very basic feature for 4 days now, what's going on? Please support newer react-native versions!

@petertoth-dev
Copy link

@darkmoor24 WHAT exactly did you do to solve it? You linked the whole thread and it's about testing running jest, and not running the project itself

@petertoth-dev
Copy link

petertoth-dev commented Oct 20, 2024

weird thing happened .... I am struggling with this for 4 days, back and forth, cleaning and nuking the project to zero etc, and today I've made a typo, and it fixed it (not sure why).

So I tried this:

  1. cd ios
  2. RCT_NEW_ARCH_ENABLED=1 pod install

this messed up everything, nothing was working so I wanted to go back to the original method, but I've made a typo (I've found it in my bash history):
I run this:
3. RCT_NEW_ARCH_ENABLED=1=0 pod install

For some reason everything is working now LOL :D

Package versions that worked:

     "react-native": "0.75.4",
     "react-native-gesture-handler": "2.20.0",
     "react-native-reanimated": "3.15.5",

@m-bert
Copy link
Contributor

m-bert commented Oct 21, 2024

Hi @petertoth-dev!

Please support newer react-native versions!

We do support newer versions of React Native, as well as New Architecture

I run this:
3. RCT_NEW_ARCH_ENABLED=1=0 pod install

For some reason everything is working now LOL :D

It works because now this variable is treated as string 1=0, and Podfile enables fabric if it is equal to 1. In other words, your app runs on paper.

@m-bert
Copy link
Contributor

m-bert commented Oct 21, 2024

Since this thread has now over 32 comments, we have to take some action. There were many suggested solutions, as well as other problems mentioned (like Unhandled SoftException com.facebook.react.bridge.ReactNoCrashSoftException: Tried to access onWindowFocusChange while context is not ready). At this point there's nothing we can do about this issue since the only reproduction works fine on our machines. I will close this issue because it seems that it is strongly connected to user setup and there's no generic solution.

If this issue is still bothering you, please open a new one. Before doing so, please first check if this project works fine. If it does, then the problem probably lies in your setup and there's not much that we can do about it. In that case you can contact as at projects@swmansion.com. Otherwise, please remember to attach minimal, reproducible example (issues without working reproduction will be closed).

@m-bert m-bert closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
@MobileMon
Copy link

MobileMon commented Oct 25, 2024

I'm also getting this same issue in an expo project

its working when i run from expo GO but when i run the app in release mode directly from xcode i encounter the error

so edit scheme -> run -> release in xcode to reproduce

and run on a physical device

@m-bert

@SSL-ACTX
Copy link

Same issue. It runs fine in Expo Go, but after building it... Got this issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests