Execution failed for task ‘:react-native-gesture-handler:compileDebugJavaWithJavac’

I am fixing a incompatibility issue related to AndroidX by adding 2 lines to gradle.properties under android for my RN 0.59.5 project.

android.useAndroidX=true
android.enableJetifier=true

Now there is another error with run-android related to react-native-gesture-handler. Then I yarn remove the current react-native-gesture-handler of 1.2.0 and add it back. The new version is 1.3.0. Here is the error:

Task :react-native-gesture-handler:compileDebugJavaWithJavac
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:3: error: package android.support.v4.util does not exist
import android.support.v4.util.Pools;
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:19: error: package Pools does not exist
private static final Pools.SynchronizedPool EVENTS_POOL =
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:3: error: package android.support.v4.util does not exist
import android.support.v4.util.Pools;
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:19: error: package Pools does not exist
private static final Pools.SynchronizedPool EVENTS_POOL =
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:20: error: package Pools does not exist
new Pools.SynchronizedPool<>(TOUCH_EVENTS_POOL_SIZE);
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:20: error: package Pools does not exist
new Pools.SynchronizedPool<>(TOUCH_EVENTS_POOL_SIZE);
^
Note: C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors

Task :react-native-gesture-handler:compileDebugJavaWithJavac FAILED

The error is related 6 packages missing and I guess it is still related to Androidx. But I have no clue how to fix it. There is an issue post#510 suggesting downgraded to version 1.0.5 for fixing but I wouldn’t like to use such an old version.

16 thoughts on “Execution failed for task ‘:react-native-gesture-handler:compileDebugJavaWithJavac’

  1. Solved by rolling back to appcompat-v7:28.0.0 Android support libraries and
    ‘yarn upgrade –pattern react-native’

  2. What did work is to downgrade React Native and do following:
    npm install react-native@0.59
    and then

    npm i react-native-gesture-handler
    react-native link react-native-gesture-handler
    .... and repeat the same with any other problem component. 
    

    Warning: watch out “npm audit fix” since it will return react-native version to 0.60 – the latest for this moment.

  3. @zmGitHub
    npm i jetifier
    npx jetify
    fixed it for me on rn 0.6

    How do this using yarn?

    1.- Add jetifier as dev dependency
    yarn add jetifier --dev

    2.- Add a task in package.json inside of “scripts” tag,

    "scripts": {
    ....
    "jetify": "npx jetify"
    }
    

    3.- Run as yarn
    yarn jetify

  4. try adding this in android/app/build.gradle -> dependencies {} . It solved my problem after upgrading RN to v0.60.4
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

  5. Placed android.useAndroidX=true
    android.enableJetifier=true
    in gadle.properties
    and
    npm i jetifier
    npx jetify
    fixed it for me on rn 0.59.9

  6. Placed android.useAndroidX=true
    android.enableJetifier=true
    in gadle.properties
    and
    npm i jetifier
    npx jetify
    fixed it for me on rn 0.59.9

    0.59.5 Works here! Thanks!!

Execution failed for task ‘:react-native-gesture-handler:compileDebugJavaWithJavac’.

I’ve completely followed the “Getting Started” section but i’m facing this bug below when i try to run react-native run-android. Does anyone have any idea on what I might be doing wrong?

> Task :react-native-gesture-handler:compileDebugJavaWithJavac FAILED
/home/matheus/Documentos/Trampos/offdriverclientes/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java:54: error: cannot find symbol
            String overflow = ((ReactViewGroup) view).getOverflow();
                                                     ^
  symbol:   method getOverflow()
  location: class ReactViewGroup
Note: /home/matheus/Documentos/Trampos/offdriverclientes/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-gesture-handler: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 1s
19 actionable tasks: 1 executed, 18 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

1 possible answer(s) on “Execution failed for task ‘:react-native-gesture-handler:compileDebugJavaWithJavac’.