software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.12k stars 980 forks source link

'RNGestureHandlerModule' could not be found. #3030

Closed Anusha-mathur closed 3 months ago

Anusha-mathur commented 3 months ago

Description

Bridgeless mode is enabled (NOBRIDGE) 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: true. TurboModule interop: true. Modules loaded: {"NativeModules":[],"TurboModules":["PlatformConstants","LogBox","SourceCode","AppState","BlobModule","WebSocketModule","DevSettings","DevToolsSettingsManager","Networking","Appearance","DevLoadingView","DeviceInfo","ImageLoader","SoundManager","IntentAndroid","DeviceEventManager"],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","HeadlessJsTaskSupport","LinkingManager","ReanimatedModule","RNGestureHandlerModule"]} (NOBRIDGE) LOG Running "trendlyne_app" with {"rootTag":11,"initialProps":{},"fabric":true} (NOBRIDGE) ERROR Invariant Violation: "trendlyne_app" has not been registered. This can happen if:

react-native: 0.74.3
react-native-gesture-handler: "2.18.1",

possible duplicate of - https://github.com/software-mansion/react-native-gesture-handler/issues/2847 I want to know the root cause of this issue, While debugging I found all these modules mentioned are null. What is the thing that is causing these types of issues, Checked so many issues but no one has given the root cause of these issues.

Screenshot_1722925918

Steps to reproduce

Upgraded the react native version from 0.73 -> 0.74.3 Once I tried to build the app, it crashed as soon as it started.

Snack or a link to a repository

https://snack.expo.dev/?platform=android

Gesture Handler version

2.18.1

React Native version

0.74.3

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Android emulator

Device model

Pixel 6

Acknowledgements

Yes

m-bert commented 3 months ago

Closing as duplicate of #2847

saikiran-photon commented 3 months ago

@m-bert if you are closing this issue. then tag related to android platform should be added in #2847 or for android it should be tracked here

m-bert commented 3 months ago

@saikiran-photon This issue seems to be platform-independent so it won't be tracked under 2 separate issues. I've added relevant tag in #2847.

Also, it would be great if you could provide a reproduction, it would be much easier to find root cause of this problem.

saikiran-photon commented 3 months ago

@m-bert I didnt see this issue recently. Earlier i noticed this issue and when hardcoding the version i got solved temporarily.

Now since yesterday the android app for me is not working at all after installing node modules newly. i'm getting different issue

m-bert commented 3 months ago

i'm getting different issue

What exactly do you mean by that?

Anusha-mathur commented 3 months ago

@m-bert For the past month I have been following the #2847 issue for resolution but nothing seemed to work on my end. I even updated the library version from 2.17.1 to 2.18.1. I just need your little guidance regarding what can be the cause of the issue, and in what circumstances this issue can occur. I will try to fix this on my end.

m-bert commented 3 months ago

@Anusha-mathur Unfortunately we don't have such information 😞 At the moment we don't have much. Moreover, we couldn't reproduce this problem. Would it be possible to take a look at your project? If not, do you have any information that may help reproduce it?

saikiran-photon commented 3 months ago

@m-bert Im getting below issue when i run in debug mode.

node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (375, 5): Not enough information to infer type variable

If i tried assembleRelease Im getting the below issue

Screenshot 2024-08-07 at 2 42 07 PM

This kept happening from yesterday evening IST after i install node modules freshly. it is in local as well as in automated pipelines too

m-bert commented 3 months ago

@saikiran-photon this looks like something else (I don't know if those 2 problems are connected or not, at first sight it seems that they are not).

Which version of Gesture Handler do you use? Line mentioned in your error message doesn't look like its actual source. Moreover, as far as I can see last change to this file was made 6 months ago.

Do you have full logs for assembleRelease case, or is it the same as the first error?

Also if it's true that those 2 issues are not connected, it would be better to open new issue and continue our discussion under the new one. Remember to prepare a reproduction that we can look at.

saikiran-photon commented 3 months ago

@m-bert I'm trying to investigate more on this issue. yes the file change that you are mentioning is not done recently. but with the node modules that i have 2 days back is working fine in my local. but with the fresh one its not working.

Will create a bug for separate discussion on this once im done with my analysis.

m-bert commented 3 months ago

Does Gesture Handler version differ between those node_modules?

saikiran-photon commented 3 months ago

no. it is not differing. we are using the older version ^2.9.0 in both the cases. I tried to increase the version to 2.15.0. there i'm getting different issue like

error: Error: Unable to resolve module ./EnableExperimentalWebImplementation from /node_modules/react-native-gesture-handler/src/index.ts:

m-bert commented 3 months ago

Have you reset all caches (yarn/npm)? Do you start your metro server with --reset-cache flag? In 2.15.0 file EnableExperimentalWebImplementation no longer exists and it was renamed to EnableNewWebImplementation.

Maybe problem lies in your repo structure - is that monorepo? Do you have more than 1 version of Gesture Handler installed?

m-bert commented 3 months ago

Also, have you changed your code to match those changes? Since 2.10.0 you no longer have to call enableExperimentalWebImplementation - it is done by default.

saikiran-photon commented 3 months ago

I tried --reset-cache but it didnt work. And for the changes of code that you were specifying about i haven't changes any code i upgraded the package to 2.15.0 and then did all the installation setup. but didnt changed anything related to code.

saikiran-photon commented 3 months ago

I Believe the issue is not happening because of the library. so issue with the setup itself. i will check more on the local setup that i had. thank you @m-bert ....

m-bert commented 3 months ago

Now I'm not sure about which issue you're talking 😅 But my guess is that both are caused by some sort of problems with setup. Let me know if you find something!

Anusha-mathur commented 3 months ago

@m-bert Sorry, can't share many details about the project. I can tell you the steps I took that led to this error. I have updated the React-native version from 0.73 to 0.74.3 and when I tried to run the app I got an async storage issue, after fixing that I got this error. Is the async library connected to this library or do we need a specific version of that library by any chance? I have cleaned node_modules, starting the app will npm start --reset-cache, I have cleared gradle cache as well. Where I am going wrong in setup? I have removed the library and then installed it again. I have commented out all the usage of the gesture handle library in our code but kept this one in the package.json as it is required by react-navigtaion. I have tried all the solutions available for this issue, but somehow not been able to move forward from this. This is what my package.json looks like. If you can specify which file you want to check, can share a snippet of that. Do we need to add import "react-native-gesture-handler" in index.js and App.js? I have tried to run the app by trying both the ways, but not sure.

"dependencies": {
    "@invertase/react-native-apple-authentication": "~2.0.2",
    "@react-native-async-storage/async-storage": "1.24.0",
    "@react-native-community/datetimepicker": "~8.0.0",
    "@react-native-community/netinfo": "~11.3.1",
    "@react-native-community/push-notification-ios": "~1.10.1",
    "@react-native-firebase/analytics": "20.1.0",
    "@react-native-firebase/app": "20.1.0",
    "@react-native-firebase/crashlytics": "20.1.0",
    "@react-native-firebase/in-app-messaging": "20.1.0",
    "@react-native-firebase/messaging": "20.1.0",
    "@react-native-firebase/remote-config": "20.1.0",
    "@react-native-google-signin/google-signin": "~10.0.1",
    "@react-native-masked-view/masked-view": "~0.3.0",
    "@react-navigation/drawer": "~6.7.0",
    "@react-navigation/native": "~6.1.17",
    "@react-navigation/stack": "~6.4.0",
    "@sentry/cli": "~2.18.1",
    "@sentry/react-native": "5.9.1",
    "create-react-class": "15.6.3",
    "dayjs": "^1.11.10",
    "deprecated-react-native-prop-types": "~2.2.0",
    "hermes-engine": "0.9.0",
    "lodash": "~4.17.21",
    "react": "18.2.0",
    "react-native": "^0.74.3",
    "react-native-blob-util": "0.19.9",
    "react-native-check-version": "~1.1.1",
    "react-native-device-info": "~10.6.0",
    "react-native-draggable-flatlist": "4.0.1",
    "react-native-easy-toast": "2.3.0",
    "react-native-exception-handler": "~2.10.10",
    "react-native-fbsdk": "~3.0.0",
    "react-native-gesture-handler": "2.18.1",
    "react-native-highcharts": "1.0.2",
    "react-native-iap": "12.13.2",
    "react-native-iphone-x-helper": "1.2.1",
    "react-native-keyboard-aware-scroll-view": "0.9.5",
    "react-native-linear-gradient": "2.8.2",
    "react-native-modal": "^13.0.0",
    "react-native-modal-datetime-picker": "17.1.0",
    "react-native-orientation-locker": "~1.5.0",
    "react-native-pager-view": "6.2.0",
    "react-native-pdf": "6.7.1",
    "react-native-push-notification": "8.1.1",
    "react-native-ratings": "~7.3.0",
    "react-native-raw-bottom-sheet": "2.2.0",
    "react-native-razorpay": "2.3.0",
    "react-native-reanimated": "3.13.0",
    "react-native-responsive-fontsize": "~0.5.0",
    "react-native-responsive-screen": "1.2.2",
    "react-native-restart": "0.0.22",
    "react-native-safe-area-context": "^4.8.2",
    "react-native-status-bar-height": "~2.6.0",
    "react-native-table-component": "^1.2.2",
    "react-native-vector-icons": "~9.2.0",
    "react-native-webview": "^13.10.0",
    "react-redux": "8.1.2",
    "react-select2-native": "1.2.0",
    "redux": "4.2.1",
    "redux-persist": "6.0.0",
    "save": "2.4.0",
    "string.prototype.matchall": "~4.0.5"
  },

@Anusha-mathur Unfortunately we don't have such information 😞 At the moment we don't have much. Moreover, we couldn't reproduce this problem. Would it be possible to take a look at your project? If not, do you have any information that may help reproduce it?

b

m-bert commented 3 months ago

I took the liberty of editing your comment to make package.json more readable, I hope you don't mind 😅

Is the async library connected to this library or do we need a specific version of that library by any chance?

Not really. The only place where we use async storage is in our example app, so it shouldn't be a problem (you can see that it is not specified in our main package.json), but...

It is specified in your package.json:

"dependencies": {
    "@invertase/react-native-apple-authentication": "~2.0.2",
    "@react-native-async-storage/async-storage": "1.24.0",
    ...

So probably you're using it somewhere in your project.

Do we need to add import "react-native-gesture-handler" in index.js and App.js? I have tried to run the app by trying both the ways, but not sure.

Import is not required, unless you're using something from library, like GestureDetector.

Where I am going wrong in setup?

It's hard to say given that we only have RN version and package.json. I'll try to look into this file later, maybe I'll find something. In the meantime, I have one more question:

I have updated the React-native version from 0.73 to 0.74.3

So on 0.73 it worked fine? Just to be sure, is it on new architecture?

Anusha-mathur commented 2 months ago

@m-bert Thanks for the reply.

So on 0.73 it worked fine? Just to be sure, is it on new architecture?

Yes, It was working fine on 0.73.

Just to be sure, is it on new architecture?

Yes, new architecture + bridgeless.

So probably you're using it somewhere in your project.

Yes, we are using "@react-native-async-storage/async-storage" in our project. To confirm something I asked if gesture handler is using async or not.

One more thing, if i am not using new architecture app is working fine, no errors.

petertoth-dev commented 2 weeks ago

@m-bert so what's the solution?!

  "dependencies": {
    "@react-native-async-storage/async-storage": "^2.0.0",
    "@react-native-community/netinfo": "^11.4.1",
    "@react-native-firebase/analytics": "^21.0.0",
    "@react-native-firebase/app": "^21.0.0",
    "@react-native-firebase/crashlytics": "^21.0.0",
    "@react-navigation/bottom-tabs": "^6.6.1",
    "@react-navigation/native": "^6.1.18",
    "@react-navigation/native-stack": "^6.11.0",
    "@reduxjs/toolkit": "^2.2.7",
    "@rnmapbox/maps": "^10.1.31",
    "@tanstack/react-query": "^5.59.0",
    "axios": "^1.7.7",
    "immer": "^10.1.1",
    "react": "18.3.1",
    "react-native": "0.75.4",
    "react-native-encrypted-storage": "^4.0.3",
    "react-native-gesture-handler": "^2.20.0",
    "react-native-logs": "^5.1.0",
    "react-native-mmkv": "^2.12.2",
    "react-native-reanimated": "3.15.5",
    "react-native-safe-area-context": "^4.11.0",
    "react-native-screens": "^3.34.0",
    "react-redux": "^9.1.2",
    "zustand": "^5.0.0-rc.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.75.4",
    "@react-native/eslint-config": "0.75.4",
    "@react-native/metro-config": "0.75.4",
    "@react-native/typescript-config": "0.75.4",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-native-dotenv": "^3.4.11",
    "react-test-renderer": "18.3.1",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }

RCT_NEW_ARCH_ENABLED=1 pod install made everything worse (more missing files), it made the project totally dead, even basic stuff don't work anymore.