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

null is not an object ( evaluating 'RNGestureHandlerModule.Direction') #494

Closed
blackpencil8994 opened this issue Mar 4, 2019 · 132 comments
Closed

Comments

@blackpencil8994
Copy link

@blackpencil8994 blackpencil8994 commented Mar 4, 2019

Hi,
I'm using react-native-gesture-handler within react-navigation and getting this error

null is not an object ( evaluating 'RNGestureHandlerModule.Direction')

screen shot 2019-03-05 at 1 27 51 am

my project is just simple and using the latest release of react-native-gesture-handle

... "dependencies": { "react": "16.6.3", "react-native": "0.58.6", "react-native-gesture-handler": "^1.1.0", "react-navigation": "^3.3.2" }, ...
Seem it's related to Direction.js fix web compatibility #406

Any suggestion for me to fix this?

@hamedhemmati
Copy link

@hamedhemmati hamedhemmati commented Mar 4, 2019

I am getting the same error.

Loading

@ajboxjr
Copy link

@ajboxjr ajboxjr commented Mar 4, 2019

Have you tried this? This solved my problem

  1. Right Click Libraries "Add Files to Project"
  2. /node_modules/react-native-gesture-handlers/ios/RNGestureHandler.xcodeproj
  3. Go to build phases and add libRNGestureHandler.a
  4. Run
    Good luck to you all!

Loading

@hamedhemmati
Copy link

@hamedhemmati hamedhemmati commented Mar 4, 2019

Thank you for the quick response that solved the problem for me.

Loading

@blackpencil8994
Copy link
Author

@blackpencil8994 blackpencil8994 commented Mar 5, 2019

Thanks @ajboxjr for your help,

I did follow your step and successfully run by XCode.

But it's still not working with react-native run-ios

Loading

@blackpencil8994
Copy link
Author

@blackpencil8994 blackpencil8994 commented Mar 5, 2019

Finally I did the same with new project and it worked for me.

So we need to manual linking react-native-gesture-handler with this new version

Thank you all.

Loading

@amrita6
Copy link

@amrita6 amrita6 commented Mar 6, 2019

Hi, I have the same issue in Android app. Could you please help me to fix it?

EDIT:
This issue appears only if I do not update MainActivity.java. After updating this file react-native run-android is failed:

$ react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat install Debug)... FAILURE: Build failed with an exception. * Where:
Settings file 'D:\testProj\react-native\navigation\android\settings.gradle' line : 3 * What went wrong:
Could not compile settings file 'D:\testProj\react-native\navigation\android\set tings.gradle'. > startup failed:
settings file 'D:\testProj\react-native\navigation\android\settings.gradle': 3 : unexpected char: '' @ line 3, column 133.
s\react-native-gesture-handler\android') ^ 1 error * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 0s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html Command failed: gradlew.bat installDebug Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (D:\testProj\react-native\navigation\node_modules\react-n ative\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (D:\testProj\react-native\navigation\node_modules\react-nativ e\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (D:\testProj\react-native\navigation\node_m odules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)

I have tried to make an installation on a new project and this error still appears.

Loading

@blackpencil8994
Copy link
Author

@blackpencil8994 blackpencil8994 commented Mar 6, 2019

@amrita6 you can link automatically in Android. But you need to manual link in iOS project.
After install package, try this:

  1. Manual link for iOS project in XCode
  2. Rename ios folder into iosX
  3. Automatically link for Android by react-native link react-native-gesture-handler
  4. Rename iosX folder into ios in turn
  5. Run

Hope this helps.

Loading

@amrita6
Copy link

@amrita6 amrita6 commented Mar 6, 2019

@blackpencil8994 thanks but I needed Android only.
I have found the reason already: in /android/settings.gradle there was string:
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')

I've changed this to:
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\\node_modules\\react-native-gesture-handler\\android')

and this helped me. Strange that it has happened so.

Loading

@markhker
Copy link

@markhker markhker commented Mar 7, 2019

@blackpencil8994 thanks but I needed Android only.
I have found the reason already: in /android/settings.gradle there was string:
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')

I've changed this to:
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')

and this helped me. Strange that it has happened so.

Two strings are the same...

Loading

@amrita6
Copy link

@amrita6 amrita6 commented Mar 7, 2019

@markhker strange but there was two backslashes but it showed as one. I've changed it already.

Loading

@joshverd
Copy link

@joshverd joshverd commented Mar 8, 2019

I'm still getting this after trying everything above, same versions as mentioned previously.

Loading

@JosephDunivan
Copy link

@JosephDunivan JosephDunivan commented Mar 9, 2019

I'm having this same issue. Why would I need to manually link in iOS. I actually went into my xCode project and its linked fine.

Loading

@JosephDunivan
Copy link

@JosephDunivan JosephDunivan commented Mar 9, 2019

I looked in GestureHandler.js and its says import Directions from ./Directions;, but no such object Directions exists in Directions.js. It sets NativeModules from react-native to RNGestureHandlerModule with method .Direction (which doesn't exist). Produces error null is not and object (evaluating 'RNGestureModule.Direction')

Loading

@denieler
Copy link

@denieler denieler commented Mar 9, 2019

same issue here :(

Loading

@denieler
Copy link

@denieler denieler commented Mar 9, 2019

ok, in my case solved by adding:

import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
....
protected List<ReactPackage> getPackages() {
        // Add additional packages you require here
        // No need to add RnnPackage and MainReactPackage
        return Arrays.<ReactPackage>asList(
            ....
            new RNGestureHandlerPackage()
        );
    }

to android/app/src/main/java/com/projectname/MainApplication.java

Loading

@joshverd
Copy link

@joshverd joshverd commented Mar 9, 2019

I ended up just giving up and building my own navigation component, haha.

Loading

@cyphire
Copy link

@cyphire cyphire commented Mar 10, 2019

I may have the answer to this!!!!

I was in some of my ES6 constants file... and I added a TouchableOpacity by accident, instead of the usual TouchableHighlight in some JSX.

My editor (Visual Studio Code) seemed to have added:
import { TouchableOpacity } from 'react-native-gesture-handler';
at the top of my file!!! WIthout my asking for it!

Go see if this was put into your code by accident, got the same error as all of you! Nothing to do with some of these comments!

It also puts an erronous console import as well when i use console for the first time in a file!

Anyway, had the error, noticed the bad import at the top and now all ok!!!

Loading

@darbio
Copy link

@darbio darbio commented Mar 11, 2019

Have you tried this? This solved my problem

  1. Right Click Libraries "Add Files to Project"
  2. /node_modules/react-native-gesture-handlers/ios/RNGestureHandler.xcodeproj
  3. Go to build phases and add libRNGestureHandler.a
  4. Run
    Good luck to you all!

Where do you do this? In XCode?

Loading

@darbio
Copy link

@darbio darbio commented Mar 11, 2019

For other people, rebuilding and deploying from XCode solved this issue for me. I didn't realise that once you link, you need to re-build and deploy (which makes total sense now that I understand what linking is!)

Loading

@tansangxtt
Copy link

@tansangxtt tansangxtt commented Mar 13, 2019

Hi,
I'm using react-native-gesture-handler within react-navigation and getting this error

null is not an object ( evaluating 'RNGestureHandlerModule.Direction')

screen shot 2019-03-05 at 1 27 51 am

my project is just simple and using the latest release of react-native-gesture-handle

... "dependencies": { "react": "16.6.3", "react-native": "0.58.6", "react-native-gesture-handler": "^1.1.0", "react-navigation": "^3.3.2" }, ...
Seem it's related to Direction.js fix web compatibility #406

Any suggestion for me to fix this?

Hi @blackpencil8994,

I also got this problem, but it can be run by react-native run-ios/android. Could you run it with Metro Bundler?

Loading

@jin-benben
Copy link

@jin-benben jin-benben commented Mar 16, 2019

I am getting the same error in android

Loading

@khattab93
Copy link

@khattab93 khattab93 commented Mar 18, 2019

After I followed the steps here https://reactnavigation.org/docs/en/getting-started.html, I got the same issue and I solved it as follows:
1- Manually linking RNGestureHandler in Xcode (Apply @ajboxjr solution with the steps mentioned here https://facebook.github.io/react-native/docs/linking-libraries-ios)
2- Uninstall the app
3- Rebuild and rerun the app using Xcode

Loading

@thefiscina
Copy link

@thefiscina thefiscina commented Mar 18, 2019

https://pt.stackoverflow.com/questions/345084/undefined-is-not-an-object-evaluating-rngesturehandlermodule-state

Funcionou para mim no android!
It worked for me on Android!

Loading

@Gauravmokashi
Copy link

@Gauravmokashi Gauravmokashi commented Mar 19, 2019

I am getting the same error in android

Have you solve this?

Loading

@Gauravmokashi
Copy link

@Gauravmokashi Gauravmokashi commented Mar 19, 2019

Have you tried this? This solved my problem

  1. Right Click Libraries "Add Files to Project"
  2. /node_modules/react-native-gesture-handlers/ios/RNGestureHandler.xcodeproj
  3. Go to build phases and add libRNGestureHandler.a
  4. Run
    Good luck to you all!

which libraries you are talking about?

Loading

@kidmysoul
Copy link

@kidmysoul kidmysoul commented Mar 20, 2019

in android、I resolved it by react-native start --reset-cache

Loading

@osdnk
Copy link
Contributor

@osdnk osdnk commented Mar 20, 2019

So AFAIK it's just a matter of restarting and rebuilding.

Loading

@osdnk osdnk closed this Mar 20, 2019
@orsospatrick
Copy link

@orsospatrick orsospatrick commented Mar 20, 2019

On Android for this I used : react-native link react-native-gesture-handler after installed react-native-gesture-handler and I solve the problem.

Loading

@HunnainKhan
Copy link

@HunnainKhan HunnainKhan commented Mar 21, 2019

For me just running
react-native link
command worked for me after re installing some libraries like react navigation

Loading

@jakub-gonet jakub-gonet reopened this Jul 24, 2020
@jakub-gonet
Copy link
Member

@jakub-gonet jakub-gonet commented Jul 24, 2020

Oh, it was closed, nevermind 😄

Loading

@hallowcard13
Copy link

@hallowcard13 hallowcard13 commented Jul 29, 2020

@amrita6 you can link automatically in Android. But you need to manual link in iOS project.
After install package, try this:

  1. Manual link for iOS project in XCode
  2. Rename ios folder into iosX
  3. Automatically link for Android by react-native link react-native-gesture-handler
  4. Rename iosX folder into ios in turn
  5. Run

Hope this helps.

HI can you please explain the first method, sorry i'm new into React Native

Loading

@Mubeyd
Copy link

@Mubeyd Mubeyd commented Sep 5, 2020

run cd android && ./gradlew clean before react-native run-android
:)

Loading

@mariohmol
Copy link

@mariohmol mariohmol commented Sep 25, 2020

Still with this issue even after following the throublshooting, which asks for unlink.. but i've seen solutions here asking to link and didn't work

[Fri Sep 25 2020 17:24:47.710]  BUNDLE  ./index.js 

[Fri Sep 25 2020 17:25:07.300]  ERROR    TypeError: undefined is not an object (evaluating '_RNGestureHandlerModule.default.Direction')
[Fri Sep 25 2020 17:25:07.301]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Fri Sep 25 2020 17:25:07.302]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
```

Loading

@rizwanellahi
Copy link

@rizwanellahi rizwanellahi commented Sep 29, 2020

Still with this issue even after following the throublshooting, which asks for unlink.. but i've seen solutions here asking to link and didn't work

[Fri Sep 25 2020 17:24:47.710]  BUNDLE  ./index.js 

[Fri Sep 25 2020 17:25:07.300]  ERROR    TypeError: undefined is not an object (evaluating '_RNGestureHandlerModule.default.Direction')
[Fri Sep 25 2020 17:25:07.301]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Fri Sep 25 2020 17:25:07.302]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

Facing the same issue.

Loading

@mariohmol
Copy link

@mariohmol mariohmol commented Sep 29, 2020

@rizwanellahi what I did was finding a working example on web and work from there... if u try to setup from scratch following the docs u will face this issue

Loading

@tiendq
Copy link

@tiendq tiendq commented Oct 31, 2020

run cd android && ./gradlew clean before react-native run-android
:)

Thank you, the most simple trick here, it worked like a charm :)

Loading

@daydreaminblue
Copy link

@daydreaminblue daydreaminblue commented Nov 20, 2020

if none of answers worked, just assume that you must :
remove react-native-cli package globally (if you started project with npx react-native init)
and delete system gradle cache (for windows : C:\Users\ [username] \ .gradle\caches)
then rebuild the app (for android :use gradlew command in android folder and in root npx react-native run android)

Loading

@oguzhancelikarslan
Copy link

@oguzhancelikarslan oguzhancelikarslan commented Dec 4, 2020

react-native link

great!

Loading

@purplecones
Copy link

@purplecones purplecones commented Dec 16, 2020

For what it's worth, I had the same issue but only for Android. In my case, I jumped into an existing codebase that was initially only built for iOS with the goal of making the app work on Android as well. To resolve this issue, I had to update the react-native.config.js file and comment out the following:

module.exports = {
  dependencies: {
    // 'react-native-gesture-handler': {
    //   platforms: {
    //     android: null,
    //     ios: null,
    //   },
    // },
  },
};

Not sure why this was added to begin with but it resolved the error above. Now both Android and iOS builds load up fine.

Loading

@Sayyamabbasi786
Copy link

@Sayyamabbasi786 Sayyamabbasi786 commented Dec 26, 2020

import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;

went into new error of Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager android error

Loading

@jakub-gonet
Copy link
Member

@jakub-gonet jakub-gonet commented Dec 28, 2020

I'm locking this issue due to spam. Please open a new issue with a reproducible example if this problem still exists.

Loading

@software-mansion software-mansion locked and limited conversation to collaborators Dec 28, 2020
someonewithpc added a commit to someonewithpc/masked-view that referenced this issue Jan 27, 2021
someonewithpc added a commit to someonewithpc/react-native-reanimated that referenced this issue Jan 27, 2021
someonewithpc added a commit to someonewithpc/react-native-safe-area-context that referenced this issue Jan 27, 2021
someonewithpc added a commit to someonewithpc/react-native-screens that referenced this issue Jan 27, 2021
janicduplessis pushed a commit to th3rdwave/react-native-safe-area-context that referenced this issue Jan 27, 2021
Szymon20000 pushed a commit to software-mansion/react-native-reanimated that referenced this issue Feb 1, 2021
## Description

This was necessary to fix software-mansion/react-native-gesture-handler#494


## Changes

Update Android Tools gradle version



## Test code and steps to reproduce

Following https://reactnative.dev/docs/navigation with a new project fails (at least with the Typescript template)
Naturalclar pushed a commit to react-native-masked-view/masked-view that referenced this issue Jul 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet