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

Comments

@blackpencil8994
Copy link

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

I am getting the same error.

@ajboxjr
Copy link

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!

@hamedhemmati
Copy link

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

@blackpencil8994
Copy link
Author

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

@blackpencil8994
Copy link
Author

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.

@amrita6
Copy link

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.

@blackpencil8994
Copy link
Author

@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.

@amrita6
Copy link

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.

@markhker
Copy link

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...

@amrita6
Copy link

amrita6 commented Mar 7, 2019

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

@joshverd
Copy link

joshverd commented Mar 8, 2019

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

@JosephDunivan
Copy link

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.

@JosephDunivan
Copy link

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')

@denieler
Copy link

denieler commented Mar 9, 2019

same issue here :(

@denieler
Copy link

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

@joshverd
Copy link

joshverd commented Mar 9, 2019

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

@cyphire
Copy link

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!!!

@darbio
Copy link

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?

@darbio
Copy link

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!)

@tansangxtt
Copy link

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?

@jin-benben
Copy link

I am getting the same error in android

@khattab93
Copy link

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

@thefiscina
Copy link

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!

@Gauravmokashi
Copy link

I am getting the same error in android

Have you solve this?

@Gauravmokashi
Copy link

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?

@kidmysoul
Copy link

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

@osdnk
Copy link
Contributor

osdnk commented Mar 20, 2019

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

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

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

@HunnainKhan
Copy link

HunnainKhan commented Mar 21, 2019

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

@jakub-gonet
Copy link
Member

Oh, it was closed, nevermind 😄

@hallowcard13
Copy link

@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

@Mubeyd
Copy link

Mubeyd commented Sep 5, 2020

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

@mariohmol
Copy link

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)
```

@rizwanellahi
Copy link

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.

@mariohmol
Copy link

@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

@tiendq
Copy link

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 :)

@daydreaminblue
Copy link

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)

@oguzhancelikarslan
Copy link

react-native link

great!

@purplecones
Copy link

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.

@Sayyamabbasi786
Copy link

import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;

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

@jakub-gonet
Copy link
Member

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

@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.