'" com.swmansion.gesturehandler.react" ERROR APPEARS

When i tried to setup React navigation, i also installed react native gesture handler.

I have added the all the required thinks as per the link below in Main Activity class.

https://reactnavigation.org/docs/en/getting-started.html

Am getting these bugs:

\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

This there any work around ? AM banging my head for past 2 days. Or do i have to setup something in gradle. I have linked the react react gesture but still it doesn't work for me.



Solution 1:[1]

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;

Solution 2:[2]

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
        );
   }

Solution 3:[3]

Add this line to your build.gradle(Module: app) file implementation project(':react-native-gesture-handler')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Iúri Batista Teles
Solution 3 Ali Yar Khan