Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix missing package "com.swmansion.gesturehandler.react"?

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.

like image 275
Ankit Jayaprakash Avatar asked Jun 15 '26 17:06

Ankit Jayaprakash


2 Answers

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;
like image 99
Naruto Uzumaki Avatar answered Jun 17 '26 08:06

Naruto Uzumaki


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
        );
   }
like image 20
Iúri Batista Teles Avatar answered Jun 17 '26 09:06

Iúri Batista Teles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!