When I tried to set up React navigation, I also installed React Native gesture handler.
I have added all the required things into the Main Activity class by following guidelines from https://reactnavigation.org/docs/3.x/getting-started
After that I'm getting the following error message:
\MainActivity.java:9: error: package com.swmansion.gesturehandler.react does not exist
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
^
D:\ReactNative\taskproject\android\app\src\main\java\com\taskproject\MainActivity.java:28: error: cannot find symbol
return new RNGestureHandlerEnabledRootView(MainActivity.this);
^
symbol: class RNGestureHandlerEnabledRootView
2 errors
Is there any workaround? I'm banging my head for the past 2 days. Or do I have to set up something in Gradle? I have linked the React gesture, but it still doesn't work for me.
I was copying mainapplication from old projects
My problem was this line:
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
was replaced by this:
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
After follow the installation guide link, I needed to add:
On android\settings.gradle
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
and run "react-native start"
And, finally, I add on android/app/src... MainAplication.java
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
and
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
....
new RNGestureHandlerPackage() <----- here
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With