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.default.Direction') #676

Closed
mohammad-yousuf opened this issue Jul 8, 2019 · 105 comments

Comments

@mohammad-yousuf
Copy link

Screenshot_1562558557

I'm having this issue in Android with react-nagivation and react-native-gesture-handler latest release. kindly help

@mohammad-yousuf
Copy link
Author

mohammad-yousuf commented Jul 9, 2019 via email

@SeaMoonTime
Copy link

I have the same questions.

@SeaMoonTime
Copy link

In 0.60, this is an awful bug. Please solve it as soon as possible.

@har2008preet
Copy link

pod install on ios folder works for me

cd ios
pod install

@m2mathew
Copy link

m2mathew commented Jul 9, 2019

This worked. Thanks, @har2008preet! 🚀

pod install on ios folder works for me

cd ios
pod install

@dangtienngoc
Copy link

How resolve it on Android and Window system.

@SeaMoonTime
Copy link

it works well in iOS, but still fail to run in Android. Who can tell me how to solve the bug in Android?

@dangtienngoc
Copy link

I run my app on Android successfully with react-native-gesture-handler

  1. I disable autoliking
  2. Using jetify to fix Android X in this time.

@MrHazimAli
Copy link

@dangtienngoc , can you help how to use jetify to fix android X?

@dangtienngoc
Copy link

@dangtienngoc , can you help how to use jetify to fix android X?

You can check it here: https://github.com/mikehardy/jetifier

@dangtienngoc
Copy link

dangtienngoc commented Jul 10, 2019

@MrHazimAli I do a video my step resolve issue here:

@MrHazimAli
Copy link

thanks @dangtienngoc , working!

@SeaMoonTime
Copy link

thanks @dangtienngoc , it works!!!!

@0xinhua
Copy link

0xinhua commented Jul 10, 2019

many thanks for your video. @dangtienngoc , I use jetifier It was been build successful.
A anoter error in emulator :
TypeError: null is not an object (evaluating '_RNGestureHandlerModule.default.createGestureHandler') This error is located at in PanGestureHandler (at StackViewLayout.tsx:372)
Any solutions?

@meraklis56
Copy link

In [email protected] it doesn't work. I still get the same error, even after jetify "null is not an object ( evaluating 'RNGestureHandlerModule.default.Direction')"

@0xinhua
Copy link

0xinhua commented Jul 10, 2019

@meraklis56 try to commenting this line:

// export { default as Directions } from './Directions';

in the your project -> node_modules -> react-native-gesture-handler -> GestureHandler.js

Good luck.

@meraklis56
Copy link

Now the error is:

07-10 16:20:38.993 16011 16348 E ReactNativeJS: null is not an object (evaluating '_RNGestureHandlerModule.default.handleSetJSResponder')
07-10 16:20:39.067 16011 16348 E ReactNativeJS: null is not an object (evaluating '_RNGestureHandlerModule.default.handleClearJSResponder')

@dangtienngoc
Copy link

In [email protected] it doesn't work. I still get the same error, even after jetify "null is not an object ( evaluating 'RNGestureHandlerModule.default.Direction')"

[email protected] not support android X yet, check your react native cli

^2.0.0 => ^0.60.0
^1.0.0 => ^0.59.0

Because react native cli ^2.0.0 support auto linking module

@GeronimoKTT
Copy link

GeronimoKTT commented Jul 10, 2019

In [email protected] it doesn't work. I still get the same error, even after jetify "null is not an object ( evaluating 'RNGestureHandlerModule.default.Direction')"

Remove this modification: // export { default as Directions } from './Directions';

And if you specified something in your "react-native.config.js", remove it.

add these lines in your MainActivity.java:
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

And add this inside the MainActivity class, just after protected String getMainComponentName() function
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}

And after that do:
cd android
gradlew clean
cd ..

Then do the usual: react-native run-android, and give me the output.
Good luck.

@petkir
Copy link

petkir commented Jul 10, 2019

please check your MainApplication.java
with react-native 0.60 looks like:

@Override
protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      return packages;
}

if you do not use Autolink function this package will not added try to add

... 
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new RNGestureHandlerPackage() );
return packages

and don't forget the import
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;

Please give feedback if it works

@HeWenKe
Copy link

HeWenKe commented Jul 11, 2019

I installed the new version yesterday, using this

image

show. same error ,it is not good to follow the method provided below and keep reporting errors. who can help me ?thinksyou waiting for this , dependencies: "dependencies": { "react": "16.8.6", "react-native": "0.60.0", "react-native-gesture-handler": "^1.3.0", "react-navigation": "^3.11.0" },

@HeWenKe
Copy link

HeWenKe commented Jul 11, 2019

Has this problem been solved? I made the same mistake as ios.

@meraklis56
Copy link

@GeronimoKTT

In [email protected] it doesn't work. I still get the same error, even after jetify "null is not an object ( evaluating 'RNGestureHandlerModule.default.Direction')"

Remove this modification: // export { default as Directions } from './Directions';

And if you specified something in your "react-native.config.js", remove it.

add these lines in your MainActivity.java:
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

And add this inside the MainActivity class, just after protected String getMainComponentName() function
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}

And after that do:
cd android
gradlew clean
cd ..

Then do the usual: react-native run-android, and give me the output.
Good luck.

I failed to mention that I am using React-Native-Navigation thus, according to installing guides I should ignore those steps and wrap every screen component using gestureHandlerRootHOC on the JS side, instead. The moment I am just importing the react-native-gesture-handler, i get the aforementioned error.

@GeronimoKTT
Copy link

Ok, which version of react-native-gesture-handler are you using?

@meraklis56
Copy link

"react": "^16.8.6",
"react-native": "^0.59.10",
"react-native-gesture-handler": "^1.3.0"

@GeronimoKTT
Copy link

Ok, can I have a look to your MainApplication.java, build.gradle (from app/) and your react-native.config.js (if you have one)

@mohammad-yousuf
Copy link
Author

Finally, I quit React Native. Either you can waste your time fixing bugs or you can make your project, it's on your luck.

@mohammad-yousuf
Copy link
Author

Facebook should spare some time on fixing RN for windows, not everyone uses a mac.

@bailer
Copy link

bailer commented Jul 11, 2019

For iOS I had to manually add this to the Podfile pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec' and then run pod install for it to work

@agorf
Copy link

agorf commented Jul 11, 2019

Running react-native unlink react-native-gesture-handler plus what @GeronimoKTT suggested is the only thing that worked for me on Android (React Native 0.60)

My woes were caused by following the installation instructions of React Navigation which seem to be outdated for RN 0.60

@aabreu
Copy link

aabreu commented Feb 28, 2020

In my case use_native_modules! was missing from my Podfile, that will make pod install to install the missing module(s)

@Frends23
Copy link

This worked for me
npm install --save react-native-gesture-handler
react-native link
Again
cd ios
pod install

@cjayprime
Copy link

As it turned out all I needed was a gradle clean (./gradlew clean) and then copying the "\android\app\build\outputs\apk\debug\app-debug.apk" manually into the device and installing (also manually) and all errors vanished.

@cjayprime
Copy link

In case anyone needs the versions:
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.4",
"react-dom": "~16.9.0",
"react-native-gesture-handler": "~1.5.0",
"react-native-safe-area-context": "0.6.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-web": "~0.11.7",
"@react-native-community/datetimepicker": "^2.2.3",
"@react-native-community/masked-view": "0.1.5",
"@react-navigation/bottom-tabs": "^5.0.0",
"@react-navigation/native": "^5.0.0",
"@react-navigation/stack": "^5.0.0",
"@react-navigation/web": "~1.0.0-alpha.9"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},

@kasaiee
Copy link

kasaiee commented Mar 9, 2020

@MrHazimAli I do a video my step resolve issue here:

video link expired!

@KunchalaSai789
Copy link

Just close the terminal and delete the app and run it again it will do it.

@Macilias
Copy link
Contributor

Macilias commented Mar 11, 2020

Just close the terminal and delete the app and run it again it will do it.

how do you want to run a deleted app?
I suppose you mean a clean build. I did it multiple times, also with deleting node_modules and caches.
Non of it helped :(

@ruyneto
Copy link

ruyneto commented Mar 13, 2020

This happens to me after installed React Navigation with the Android Simulator opened before.

So...I've

1 - finished the process

2- deleted the App in Simulator

3 - run npx react-native run-android again,

worked.

Maybe React cannot update his new deps on an old installed App?

@Ben-Malik
Copy link

Ben-Malik commented Mar 20, 2020

If you get this error on iOS but the android version works fine, Do this:

  1. Go to node_modules > react-native-gesture-handler > GestureHandler.js.
  2. In there, comment this line:
    export { default as Directions } from './Directions';

And there you go!!!

@gabrielbauer
Copy link

@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}

You're my hero!

@peguimasid
Copy link

peguimasid commented Mar 26, 2020

i trying to fix this for 4 hours, if you are running in mac and try to use the ios simulator ty to do this:

cd ios
pod install

but after this restart the server and i think is gonna works, just like work for me

@BisratYalew
Copy link

I am using "react-native": "0.61.5"
I am working on ubuntu 18.04
I fixed the issue on my android emulator by following the steps mentioned below

Make sure you follow steps for the version you are using (React Native 0.61.5 and lower in my case)

  1. Delete/Remove your node_modules directory
    rm -rf node_modules

  2. Install your dependencies again
    If you are using Yarn $ yarn or npm install if you are using npm

  3. Clean your Gradle
    I followed below steps for that:

cd android
./gradlew clean
cd ..
react-native run-android

Good Luck, These steps worked for me

@whitecodel
Copy link

I am using "react-native": "0.61.5"
I am working on ubuntu 18.04
I fixed the issue on my android emulator by following the steps mentioned below

Make sure you follow steps for the version you are using (React Native 0.61.5 and lower in my case)

  1. Delete/Remove your node_modules directory
    rm -rf node_modules
  2. Install your dependencies again
    If you are using Yarn $ yarn or npm install if you are using npm
  3. Clean your Gradle
    I followed below steps for that:

cd android
./gradlew clean
cd ..
react-native run-android

Good Luck, These steps worked for me

thanks this trick work for me

@BisratYalew
Copy link

thanks this trick work for me

I am glad it worked for you!

@overwatchh
Copy link

@meraklis56 try to commenting this line:

// export { default as Directions } from './Directions';

in the your project -> node_modules -> react-native-gesture-handler -> GestureHandler.js

Good luck.

Thank you. It worked for me.

@jakub-gonet
Copy link
Member

https://reactnavigation.org/docs/troubleshooting#im-getting-an-error-null-is-not-an-object-evaluating-rngesturehandlermoduledefaultdirection

This may help some people out there.

Please provide link repo with reproduction example, we can't take any sensible action with only this screenshot.

@jakub-gonet
Copy link
Member

Duplicate of #494.

@naveedahmed986
Copy link

In [email protected] it doesn't work. I still get the same error, even after jetify "null is not an object ( evaluating 'RNGestureHandlerModule.default.Direction')"

Remove this modification: // export { default as Directions } from './Directions';

And if you specified something in your "react-native.config.js", remove it.

add these lines in your MainActivity.java:
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

And add this inside the MainActivity class, just after protected String getMainComponentName() function
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}

And after that do:
cd android
gradlew clean
cd ..

Then do the usual: react-native run-android, and give me the output.
Good luck.

I was facing the same issue on Android 9 with

"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/drawer": "^5.9.1",
"@react-navigation/native": "^5.7.4",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-gesture-handler": "^1.8.0",
"react-native-reanimated": "^1.13.1",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.11.0"

And this solution worked for me. Thanks a million!

@mariohmol
Copy link

Hi, i'm still facing this issue, the message is slightly different (instead of null is undefined)

TypeError: undefined is not an object (evaluating '_RNGestureHandlerModule.default.Direction')

@hamdirhibi
Copy link

hamdirhibi commented Oct 3, 2020

if you are using android try this solution :
go to : /android/settings.gradle there was string:
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')

tro to change it with :
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')
source : #494 (comment)

@jagtarsingh1232
Copy link

jagtarsingh1232 commented Oct 12, 2020

Hi, i'm still facing this issue,

TypeError: null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')

and this is setting.gradle

rootProject.name = 'Something'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

@jagtarsingh1232
Copy link

Hi, i'm still facing this issue,

TypeError: null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')

My ------- setting.gradle
rootProject.name = 'some'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

@liltrendi
Copy link

I was on a physical Android device debugging over Wi-Fi, the following solution worked for me:

  1. Delete the installed app from your device.
  2. Run cd android; ./gradlew clean from your project.
  3. Reinstall the app react-native run-android on your device.
  4. A server should have been started, open your installed up and it should run fine.

Hope this helps!

@sulsanaul
Copy link

If you get this error on iOS but the android version works fine, Do this:

  1. Go to node_modules > react-native-gesture-handler > GestureHandler.js.
  2. In there, comment this line:
    export { default as Directions } from './Directions';

And there you go!!!

Worked for me. Not sure what it'll break down the line though...

@lung2008123
Copy link

This worked for me
npm install --save react-native-gesture-handler
react-native link
Again
cd ios
pod install

This ios solution works for me!

My project hasn't utilizing 'react-native-gesture-handler', but it solves the bug. My best guess is the error could be from 'react-native-gesture-handler' implicitly required by 'react-native-navigation' - after a few dependency upgrades / downgrades / pod deintegrate / fixes in ios .xcworkspace, this could happen.

For dear Android dev fellows, try to reinstall 'react-native-gesture-handler' maybe?

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

@LHDi
Copy link

LHDi commented Dec 29, 2020

for android, I just installed jetifier as a dev-dep it worked for me.

@jakub-gonet
Copy link
Member

Closing due to spam. If you still experience this problem, open a new issue with the reproducible example.

@software-mansion software-mansion locked and limited conversation to collaborators Dec 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests