react-native-gesture-handler: 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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 18
npm install --save react-native-gesture-handler
npx pod-install ios
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.
Fixed it one time by: npm install this repo npx jetify
But now I get the same error again
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
, thennpx jetify
, but I still have the issuecannot find symbol. import com.swmansion.gesturehandler.RNGestureHandlerPackage
in my PackageList.javaHey, 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.
This is still an issue with react-native-gesture-handler 2.6.0. Exact same build failure.
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:
Package versions
iOS builds fine
@mwegener-com have you found solution?
@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;
toimport com.swmansion.gesturehandler.RNGestureHandlerPackage;
Running into this issue as well.