Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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<RNGestureHandlerEvent> 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<RNGestureHandlerStateChangeEvent> 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

FAILURE: Build failed with an exception.

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 (for RN-gesture-handler) suggesting downgraded to version 1.0.5 for fixing but I wouldn't like to use such an old version.

like image 924
user938363 Avatar asked Jun 20 '19 00:06

user938363


People also ask

How do I fix unable to resolve module react-native gesture handler?

This error occurs for two main reasons. If you didn't install react-native-gesture-handler , then npm or yarn install react-native-gesture-handler . If you already did, then you need to rebuild your app, for android react-native run-android and for ios you should install pods then run again.

What is gestures in react-native?

The gesture responder system manages the lifecycle of gestures in your app. A touch can go through several phases as the app determines what the user's intention is. For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch.


2 Answers

It cause this error for the RN 0.60. You can solve this by following,

npm i jetifier
npx jetify

fixed it for me on RN 0.60.

Have a good day.

like image 104
Harsh Panchal Avatar answered Oct 19 '22 19:10

Harsh Panchal


npm i jetifier
npx jetify

Fixed it for me on react-native 0.60

Be carefully for latest react-native version don't need

react-native link react-native-gesture-handler

It is automatically linked by react-native 0.60

like image 45
Nijat Aliyev Avatar answered Oct 19 '22 19:10

Nijat Aliyev