react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

Build fails on Android. RNGestureHandlerPackage not found

Open Humad opened this issue 5 years ago • 19 comments

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

  1. Follow installation instructions here: https://docs.swmansion.com/react-native-gesture-handler/docs/#installation
  2. 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.

Humad avatar Oct 15 '21 07:10 Humad

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

Humad avatar Oct 15 '21 07:10 Humad

And my build.gradle has the following:

dependencies {
    ...
    implementation project(':react-native-gesture-handler')
    ...
}

Humad avatar Oct 15 '21 07:10 Humad

same problem. How did you solve it?

mwegener-com avatar Nov 02 '21 13:11 mwegener-com

Fixed it one time by: npm install this repo npx jetify

But now I get the same error again Bildschirmfoto 2021-11-02 um 19 40 10

mwegener-com avatar Nov 02 '21 13:11 mwegener-com

@mwegener-com have you found solution?

Arkan4ik avatar Dec 14 '21 19:12 Arkan4ik

@mwegener-com have you found solution?

There are some other threads about this issue.

mwegener-com avatar Dec 14 '21 19:12 mwegener-com

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

veb-ioki avatar Aug 10 '22 10:08 veb-ioki

This is still an issue with react-native-gesture-handler 2.6.0. Exact same build failure.

veb-ioki avatar Aug 29 '22 09:08 veb-ioki

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.

veb-ioki avatar Aug 31 '22 13:08 veb-ioki

npm install --save react-native-gesture-handler

npx pod-install ios

yaduvanshi-studio-labs avatar Sep 08 '22 12:09 yaduvanshi-studio-labs

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

erickcrus avatar Dec 05 '22 20:12 erickcrus

Running into this issue as well.

tgreco avatar Dec 08 '22 22:12 tgreco

Having this issue right after updating to the latest [email protected]

gabriel-messas avatar Jun 22 '23 18:06 gabriel-messas

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.

dgreasi avatar Aug 22 '23 08:08 dgreasi

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.

tchejanovich avatar Aug 25 '23 18:08 tchejanovich

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.

BiigBan avatar Sep 13 '23 09:09 BiigBan

@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;

phillipkey avatar Dec 19 '23 21:12 phillipkey

react-native-gesture-handle

Thanks, ur suggestion seemed to fix my issue. npm install --save react-native-gesture-handler

kyeyunedaniel avatar Feb 01 '24 07:02 kyeyunedaniel

./gradlew clean helped me

ivanrndev-leo avatar Jan 20 '25 14:01 ivanrndev-leo