Build fails on Android. RNGestureHandlerPackage not found
Description
I'm trying to build my app for android by doing ./gradlew bundlerelease, but I am getting errors. (See below for details)
Steps To Reproduce
- Follow installation instructions here: https://docs.swmansion.com/react-native-gesture-handler/docs/#installation
- Try to build the android app by doing
./gradlew bundlerelease
Expected behavior
App builds successfully
Actual behavior
App does not build.
Getting the following error:
> Task :app:compileReleaseJavaWithJavac FAILED
/Users/humad-home/tvproject-mobile/android/app/src/main/java/com/serializdmobile/MainApplication.java:11: error: cannot find symbol
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler
/Users/humad-home/tvproject-mobile/android/app/src/main/java/com/serializdmobile/MainApplication.java:12: error: cannot find symbol
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler
/Users/humad-home/tvproject-mobile/android/app/src/main/java/com/serializdmobile/MainApplication.java:13: error: cannot find symbol
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler
/Users/humad-home/tvproject-mobile/android/app/src/main/java/com/serializdmobile/MainApplication.java:14: error: cannot find symbol
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler
/Users/humad-home/tvproject-mobile/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:33: error: cannot find symbol
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler
/Users/humad-home/tvproject-mobile/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:104: error: cannot find symbol
new RNGestureHandlerPackage(),
^
symbol: class RNGestureHandlerPackage
location: class PackageList
Note: /Users/humad-home/tvproject-mobile/android/app/src/main/java/com/serializdmobile/MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
6 errors
FAILURE: Build failed with an exception.
Package versions
- React: 16.13.1
- React Native: 0.63.4
- React Native Gesture Handler: git://github.com/software-mansion/react-native-gesture-handler.git#5572e8d65d73889f0bdb91f5aaa33cc1958971cd
(For React Native Gesture Handler, I'm on the above commit which fixes modal issues)
Other notes
This is only an issue with Android. The iOS app builds perfectly. I was able to build the Android app a few days ago. Not sure why it has stopped building now. I can't find anything in my project's commit history that indicates a breaking change.
Here's my MainActivity.java
package com.serializdmobile;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import expo.modules.splashscreen.singletons.SplashScreen;
import expo.modules.splashscreen.SplashScreenImageResizeMode;
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// SplashScreen.show(...) has to be called after super.onCreate(...)
// Below line is handled by '@expo/configure-splash-screen' command and it's discouraged to modify it manually
SplashScreen.show(this, SplashScreenImageResizeMode.CONTAIN, ReactRootView.class, false);
}
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "main";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
And my build.gradle has the following:
dependencies {
...
implementation project(':react-native-gesture-handler')
...
}
same problem. How did you solve it?
Fixed it one time by: npm install this repo npx jetify
But now I get the same error again

@mwegener-com have you found solution?
@mwegener-com have you found solution?
There are some other threads about this issue.
Did anyone find a real solution for this? (or this https://github.com/software-mansion/react-native-gesture-handler/issues/1707)
We have the same issue when trying to update from 2.2.0 to 2.5.0, Android build fails with:
/Users/<xxx>/<xxx>/<xxx>/android/app/src/main/java/com/<xxx>/<xxx>/MainApplication.java:23: error: cannot find symbol
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler.react
/Users/<xxx>/<xxx>/<xxx>/android/app/src/main/java/com/<xxx>/<xxx>/MainApplication.java:58: error: cannot find symbol
packages.add(new RNGestureHandlerPackage());
^
symbol: class RNGestureHandlerPackage
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Package versions
- React: 17.0.2
- React Native: 0.68.2
- existing version of React Native Gesture Handler: 2.2.0
iOS builds fine
This is still an issue with react-native-gesture-handler 2.6.0. Exact same build failure.
In case others are as blind and stupid as I was, this is what the problem was (for us):
We hadn't read the docs thoroughly enough 🤦♀️ and didn't update the MainActivity.java as instructed for migration to rn-gesture-handler 2:
https://docs.swmansion.com/react-native-gesture-handler/docs/guides/upgrading-to-2
https://docs.swmansion.com/react-native-gesture-handler/docs/guides/migrating-off-rnghenabledroot/
And as we are using rn-gesture-handler along with React Navigation, we also needed to do this is needed as well, because otherwise the app did not "work correctly" as mentioned said here.
npm install --save react-native-gesture-handler
npx pod-install ios
Same issue only in Android. Using react-native-gesture-handler 2.5.0 with react-native 0.65.
I install fresh package with npm install react-native-gesture-handler, then npx jetify, but I still have the issue cannot find symbol. import com.swmansion.gesturehandler.RNGestureHandlerPackage in my PackageList.java
Running into this issue as well.
Having this issue right after updating to the latest [email protected]
Same issue with the following dependencies:
"react": "18.2.0",
"react-native": "0.72.3",
"react-native-gesture-handler": "^2.12.0",
"react-native-reanimated": "^3.3.0",
"@react-navigation/bottom-tabs": "^6.5.8",
"@react-navigation/elements": "^1.3.3",
"@react-navigation/native": "^6.0.10",
"@react-navigation/native-stack": "^6.6.2",
Errors:
/react/PackageList.java:23: error: cannot find symbol
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
/react/PackageList.java:29: error: cannot find symbol
import com.swmansion.rnscreens.RNScreensPackage;
/react/PackageList.java:83: error: cannot find symbol
new RNGestureHandlerPackage(),
/react/PackageList.java:86: error: cannot find symbol
new RNScreensPackage(),
It seems there is a similar issue with react-native-screens.
Hi, I'm still having this issue.
"react-native": "0.70.0",
"react-native-gesture-handler": "2.10.0",
None of the solutions above works for me.
Hey, I noticed the same issue when I downloaded the package with Yarn. I deleted the entire node_modules directory and then reinstalled it (npm install). Now it works fine. As far as I understand, the main problem is with Yarn. I used npm before, and in this case, I installed the package with Yarn.
If you have used npm before, try installing the new package with npm (don't use Yarn), and your app will build successfully.
@tchejanovich
If you have manual dependency linking in your project, you should double check the import path for com.swmansion.gesturehandler.RNGestureHandlerPackage; in your MainApplication.
We were updating from 1.10.3 -> 2.5.0 and it looks like at some point the import path for the package was moved from
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; to import com.swmansion.gesturehandler.RNGestureHandlerPackage;
react-native-gesture-handle
Thanks, ur suggestion seemed to fix my issue. npm install --save react-native-gesture-handler
./gradlew clean helped me