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 · 86 comments

Comments

@blackpencil8994
Copy link

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

This comment has been minimized.

Copy link

commented Mar 4, 2019

I am getting the same error.

@ajboxjr

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Mar 4, 2019

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

@blackpencil8994

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

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.

@amrita6

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

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.

@amrita6

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Mar 7, 2019

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

@joshverd

This comment has been minimized.

Copy link

commented Mar 8, 2019

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

@JosephDunivan

This comment has been minimized.

Copy link

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.

@JosephDunivan

This comment has been minimized.

Copy link

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

@denieler

This comment has been minimized.

Copy link

commented Mar 9, 2019

same issue here :(

@denieler

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Mar 9, 2019

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

@cyphire

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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?

@jin-benben

This comment has been minimized.

Copy link

commented Mar 16, 2019

I am getting the same error in android

@khattab93

This comment has been minimized.

Copy link

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

@thefiscina

This comment has been minimized.

Copy link

commented Mar 18, 2019

@Gauravmokashi

This comment has been minimized.

Copy link

commented Mar 19, 2019

I am getting the same error in android

Have you solve this?

@Gauravmokashi

This comment has been minimized.

Copy link

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?

@kidmysoul

This comment has been minimized.

Copy link

commented Mar 20, 2019

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

@osdnk

This comment has been minimized.

Copy link
Collaborator

commented Mar 20, 2019

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

@osdnk osdnk closed this Mar 20, 2019

@orsospatrick

This comment has been minimized.

Copy link

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.

@HunnainKhan

This comment has been minimized.

Copy link

commented Mar 21, 2019

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

@mgfjxxiexiaolong

This comment has been minimized.

Copy link

commented Jul 5, 2019

I had this issue with iOS when trying to get it running. After following the installation instructions and linking with

react-native link react-native-gesture-handler

I then had to run

pod install

Maybe the instructions need to be updated to reflect this if you are using pods?

谢谢!我在向现有app中引入了RN,在执行离线包的时候遇到了这个问题,react-native link操作后一定要执行pod install,我的问题很好的解决了。

@dallasclark

This comment has been minimized.

Copy link

commented Jul 6, 2019

Thanks @HunnainKhan !

@johnnfujita

This comment has been minimized.

Copy link

commented Jul 6, 2019

for ios:

yarn add react-navigation
yarn add react-native-gesture-handler
react-native link react-native-gesture-handler

if it is not working:

go into ./project_folder/ios_folder/

pod install

This worked for me today... but actually the instructions on the website were working for me on my regular workstation. Software is so temperamental. ehehehehehhe..

@developerewt

This comment has been minimized.

Copy link

commented Jul 6, 2019

I was getting this error in iOS build. I ran pod install inside my ios folder and it worked.

I will run my project in iOS and Android, because of this I followed all steps in installation documentation, including the modification of MainActivity.java.

@Harsh2402

This comment has been minimized.

Copy link

commented Jul 8, 2019

Looks like this is to do with the new autolinking feature in RN 0.60. To fix for now just add the following podspec for RNGesureHandler to ios/Podfile

pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'

Then in the ios directory run pod install to install it.

@bobzhen

This comment has been minimized.

Copy link

commented Jul 9, 2019

I had this issue with iOS when trying to get it running. After following the installation instructions and linking with

react-native link react-native-gesture-handler

I then had to run

pod install

Maybe the instructions need to be updated to reflect this if you are using pods?

Thanks, this works for me

@FrozenIce0617

This comment has been minimized.

Copy link

commented Jul 9, 2019

Hi, @blackpencil8994

So manual link of react-native-gesture-handler is a must?
Please let me know.

Thanks.

@M1seRy

This comment has been minimized.

Copy link

commented Jul 10, 2019

@joshverd wise decision,I almost want to buy another new mbp to try solve this issue .🤷‍♀️

@volokolamskspb

This comment has been minimized.

Copy link

commented Jul 10, 2019

I had this issue with iOS when trying to get it running. After following the installation instructions and linking with
react-native link react-native-gesture-handler
I then had to run
pod install
Maybe the instructions need to be updated to reflect this if you are using pods?

npm install --save react-native-gesture-handler
react-native link react-native-gesture-handler
cd /ios
pod install

Also works for me on MacOS with versions: react-native-cli: 2.0.1; react-native: 0.60.0
I'm running into this error in each new project.

@Dror-Bar

This comment has been minimized.

Copy link

commented Jul 10, 2019

Looks like this is to do with the new autolinking feature in RN 0.60. To fix for now just add the following podspec for RNGesureHandler to ios/Podfile

pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'

Then in the ios directory run pod install to install it.

This, and this again. Please update the installing instructions to include this.
At the very least, move the comment regarding RN 6.0 before the part where you run the command 'npm install', otherwise automatic linking takes place, and many users will have issues.

@KellyUK

This comment has been minimized.

Copy link

commented Jul 10, 2019

This thing worked for me:
Go to node_modules/react-native-gesture-handler/GestureHandler.js
And commit this line
//export { default as Directions } from './Directions';

Thank you. If you comment out the line above it works.

@liyamahendra

This comment has been minimized.

Copy link

commented Jul 14, 2019

None of the above solutions of adding to the library and build phases worked for me. Following is what worked for me:

cd ios
pod install

Original credits here.

@AidenChen

This comment has been minimized.

Copy link

commented Jul 15, 2019

I fixed it by:

npm i jetifier -D
npx jetify

@schwamic

This comment has been minimized.

Copy link

commented Jul 15, 2019

Thx to @blackpencil8994

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.

iOS

react-native link react-native-gesture-handler did not work for iOS. I checked the Libraries folder in XCode and RNGestureHandler.xcodeproj was not listed. After following this steps react-native/docs iOS worked for me.

Android

I am using ReactNative v0.59.10 and this version doesn't support AndroidX. Therefore you should not use jetifier, I think this is for RN.0.60+ which supports AndroidX. If you only follow the ReactNavigation guide without the jetifier step, it works perfekt for Android out of the box.


PS.: I wouldn't recommend changing the code in the node_modules folder. At the latest when a colleague checks out and installs the project, he/she gets the error. Or CI/CD pipelines will fail...

@jslyonnais

This comment has been minimized.

Copy link

commented Jul 15, 2019

In react-native v0.60.0 RC 0 i had to run pod install in the ios directory and it worked fine.
I was getting the same error with just react-native link.

The pod install inside ios folder works really great! The things is it's really inconvenient for future work and colleague.

Try adding a npm script like "install": "yarn && cd ios && pod install" or something to make sure people of your team don't have the same issue.

@jackvial

This comment has been minimized.

Copy link

commented Jul 16, 2019

I had deleted the TVOS targets in xCode so Pod install was throwing an error, I deleted the TVOS folders from ios/ and removed the target checks for TVOS from the pod file, then ran pod install, rebuilt from xCode and that fixed the error.

@ramanasak

This comment has been minimized.

Copy link

commented Jul 18, 2019

I am having the same issue ,I am using react-native version 0.60.3 , in docs it says automatic linking in react-native 0.60 above version . what should i do ?

image

@nicolastanski

This comment has been minimized.

Copy link

commented Jul 18, 2019

I had this issue with iOS when trying to get it running. After following the installation instructions and linking with
react-native link react-native-gesture-handler
I then had to run
pod install
Maybe the instructions need to be updated to reflect this if you are using pods?

npm install --save react-native-gesture-handler
react-native link react-native-gesture-handler
cd /ios
pod install

Also works for me on MacOS with versions: react-native-cli: 2.0.1; react-native: 0.60.0
I'm running into this error in each new project.

It works for me. Thanks.

@ramanasak

This comment has been minimized.

Copy link

commented Jul 19, 2019

@nicolastanski I am using windows environment , does this work for window
npm install --save react-native-gestur-handler
react-native link react-native-gesture-handler

@ramanasak

This comment has been minimized.

Copy link

commented Jul 19, 2019

@nicolastanski i have used these commands earlier to install

npm install react-navigation
npm install react-navigation-gesture-handler

@bagasroman

This comment has been minimized.

Copy link

commented Jul 22, 2019

see your native react version, if version 0.60 then you must migrate to androidX using a jetifier, follow the steps in this link
https://github.com/mikehardy/jetifier

successful for me :)

@XeeshanAnsari

This comment has been minimized.

Copy link

commented Jul 22, 2019

in react-native 0.60.+ you will have to install pod.
cd ios && pod install && cd ../

@valnavarro

This comment has been minimized.

Copy link

commented Jul 25, 2019

@ma-lemire

This comment has been minimized.

Copy link

commented Aug 2, 2019

@Harsh2402 I love you man ! works well

@Saroopashree

This comment has been minimized.

Copy link

commented Aug 15, 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!

What is that Libraries? I can't understand the step 1.
Also where to add the libRNGestureHandler.a
In the Xcode project I can't add the libRNGestureHandler.a file in the Target Dependencies. Only the libRNGestureHandler-tvOS.a file is available to add in the Target Dependencies.

Help me out.

@lakkansingh

This comment has been minimized.

Copy link

commented Aug 20, 2019

I had this issue with iOS when trying to get it running. After following the installation instructions and linking with
react-native link react-native-gesture-handler
I then had to run
pod install
Maybe the instructions need to be updated to reflect this if you are using pods?

npm install --save react-native-gesture-handler
react-native link react-native-gesture-handler
cd /ios
pod install
Also works for me on MacOS with versions: react-native-cli: 2.0.1; react-native: 0.60.0
I'm running into this error in each new project.

It works for me. Thanks.

It works for me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.