React-native-gesture-handler: [Updated]RN: 0.60.0 compile error : RNGestureHandlerEnabledRootView(MainActivity.this) && "can't find symbol"

Created on 11 Jul 2019  路  12Comments  路  Source: software-mansion/react-native-gesture-handler

I'm trying to install react-navigation package to my project. I did all instructions on here and I search on GitHub, StackOverflow but can't find any solution, still getting error while compiling

My package.json:

  • "react": "16.8.6",
  • "react-native": "0.60.0",
  • "react-native-gesture-handler": "^1.3.0",
  • "react-native-safe-area-view": "^0.14.6",
  • "react-navigation": "^3.11.0",
  • "react-redux": "^7.1.0",
  • "redux": "^4.0.3"

Error output:

Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
13 actionable tasks: 2 executed, 11 up-to-date
C:\Users\ezran\Desktop\SADELABS\reduxTest\android\app\srcmain\java\com\reduxtest\MainActivity.java:6: error: package com.swmansion.gesturehandler.react does
not exist
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
^
C:\Users\ezran\Desktop\SADELABS\reduxTest\android\app\srcmain\java\com\reduxtest\MainActivity.java:24: error: cannot find symbol
return new RNGestureHandlerEnabledRootView(MainActivity.this);
^
symbol: class RNGestureHandlerEnabledRootView
2 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Users\ezran\Desktop\SADELABS\reduxTest\android\app\srcmain\java\com\reduxtest\MainActivity.java:6: error: package com.swmansion.gesturehandler.react does
not exist
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
^
C:\Users\ezran\Desktop\SADELABS\reduxTest\android\app\srcmain\java\com\reduxtest\MainActivity.java:24: error: cannot find symbol
return new RNGestureHandlerEnabledRootView(MainActivity.this);
^
symbol: class RNGestureHandlerEnabledRootView
2 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s

at checkExecSyncError (child_process.js:616:11)
at execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\ezran\Desktop\SADELABS\reduxTest\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:75:39)
at buildAndRun (C:\Users\ezran\Desktop\SADELABS\reduxTest\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:137:41)
at then.result (C:\Users\ezran\Desktop\SADELABS\reduxTest\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:103:12)
at process._tickCallback (internal/process/next_tick.js:68:7)

Any help?

EDIT: I create a new project to test on new React Native version and getting new errors. Maybe we can follow this issue for help.

Android

Most helpful comment

I've found a solution (maybe its just a hack).

So in order to pass through this issue you need to create react-native.config.js file at your project root with following content:

module.exports = {
  dependencies: {
    "react-native-gesture-handler": {
      platforms: {
        android: null,
        ios: null
      }
    }
  }
};

I've solved this issue by manually linking the lib for android:

In your MainApplication.java you will add:

package yourpackage;

...

import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
...

public class MainApplication extends Application implements ReactApplication {
    ...

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Add RNGestureHandler manually!
      packages.add(new RNGestureHandlerPackage());
      return packages;
    }
. ..

In your android/app/build.gradle add implementation project(':react-native-gesture-handler')

and inside android/settings.gradle add these two lines:

...
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
...

Now build and run and it should work (at least it worked for me...)!

_Also dont forget to use jetifier for other problems._
_Maybe you should also try to rm -rf your node_modules dir before building the app_

All 12 comments

I am experiencing the same error too. Edit: A solution might be removing android in react-native.config.js ie module.exports = { dependencies: { 'react-native-gesture-handler': { platforms: { ios: null, }, }, }, };

I am experiencing the same error too. and i tryed version 1.1.2 ,it still not work

I've created a new project and installed this package but I'm still getting the same error. My react-native version is 0.60.3

I've found a solution (maybe its just a hack).

So in order to pass through this issue you need to create react-native.config.js file at your project root with following content:

module.exports = {
  dependencies: {
    "react-native-gesture-handler": {
      platforms: {
        android: null,
        ios: null
      }
    }
  }
};

I've solved this issue by manually linking the lib for android:

In your MainApplication.java you will add:

package yourpackage;

...

import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
...

public class MainApplication extends Application implements ReactApplication {
    ...

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Add RNGestureHandler manually!
      packages.add(new RNGestureHandlerPackage());
      return packages;
    }
. ..

In your android/app/build.gradle add implementation project(':react-native-gesture-handler')

and inside android/settings.gradle add these two lines:

...
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
...

Now build and run and it should work (at least it worked for me...)!

_Also dont forget to use jetifier for other problems._
_Maybe you should also try to rm -rf your node_modules dir before building the app_

This is the same issue with me

look this https://github.com/kmagiera/react-native-gesture-handler/issues/691

if RN >= 0.60.0

vim ios/Podfile

add line code

pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'

run pod install

react-native run-ios

you can solve the problem

It works with react-native run-ios but not from Xcode (both workspace and project)

react-native gesture handler is not working after recent release can anyone tell me how i can use it??

app/src/main/java/com.xxx/MainActivity.java
change
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRoot;
to
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

I'm still experiencing this issue, I've tried all other solutions but nothing...
clean, rebuild, autolinking, manual linking, jetify, nothing works...

I'm getting always

Expect view tag to be set for com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView

my package:

"react": "16.8.6",
"react-native": "0.60.5",
"react-native-gesture-handler": "^1.4.1",
"react-native-reanimated": "^1.2.0",
"react-navigation": "^4.0.0",

thanks for any helps, I've been stuck for days :(

I've run into the same issue and after using yarn instead of using npm as the website suggests to install the packages:

npm install @react-navigation/native

& the dependencies:

npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

I used yarn to add (install) the packages and dependencies:

yarn add @react-navigation/native

&

yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

This worked for me.

This should be fixed in newer releases.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brunolemos picture brunolemos  路  3Comments

neiker picture neiker  路  3Comments

tallen11 picture tallen11  路  3Comments

chrisdrackett picture chrisdrackett  路  4Comments

muhaimincs picture muhaimincs  路  3Comments