react-native-gesture-handler: Build failed after upgrading to react-native@0.72.0

Description

error: cannot find symbol
      new RNGestureHandlerPackage(),
          ^
  symbol:   class RNGestureHandlerPackage
  location: class PackageList

image

package.json

{
    "scripts": {
        "android": "react-native run-android",
        "ios": "react-native run-ios",
        "start": "react-native start",
    },
    "dependencies": {
        "@react-native-async-storage/async-storage": "^1.18.1",
        "@react-native-community/blur": "^4.3.2",
        "@react-native-community/geolocation": "^3.0.6",
        "@react-native/metro-config": "^0.72.6",
        "@react-navigation/bottom-tabs": "^6.5.7",
        "@react-navigation/native": "^6.1.6",
        "@react-navigation/stack": "^6.3.16",
        "axios": "^1.4.0",
        "axios-auth-refresh": "^3.3.6",
        "jwt-decode": "^3.1.2",
        "react": "18.2.0",
        "react-native": "0.72.0",
        "react-native-gesture-handler": "^2.12.0",
        "react-native-keychain": "^8.1.1",
        "react-native-permissions": "^3.8.0",
        "react-native-safe-area-context": "^4.5.1",
        "react-native-screens": "^3.20.0",
        "react-native-svg": "^13.9.0",
        "react-native-svg-transformer": "^1.0.0",
        "react-native-swiper": "^1.6.0",
        "styled-components": "^5.3.10"
    },
    "devDependencies": {
        "@babel/core": "^7.21.4",
        "@babel/runtime": "^7.21.0",
        "@react-native-community/eslint-config": "^1.1.0",
        "babel-jest": "^29.5.0",
        "eslint": "^6.5.1",
        "jest": "^29.5.0",
        "metro-react-native-babel-preset": "^0.76.3",
        "react-test-renderer": "18.2.0"
    },
}

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
    }
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

I have tried to rollback versions of both the library and the gradle components but nothing worked. It also mentions several deprecations in Java code coming from the library:

> Task :react-native-gesture-handler:compileDebugKotlin
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\noreanimated\src\main\java\com\swmansion\gesturehandler\ReanimatedEventDispatcher.kt: (7, 31): Parameter 'event' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\noreanimated\src\main\java\com\swmansion\gesturehandler\ReanimatedEventDispatcher.kt: (7, 41): Parameter 'reactApplicationContext' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\core\GestureHandler.kt: (755, 11): Name shadowed: size
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.kt: (9, 51): Unreachable code
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.kt: (10, 80): Unreachable code
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootHelper.kt: (77, 18): 'onChildStartedNativeGesture(MotionEvent!): Unit' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootHelper.kt: (82, 42): Parameter 'disallowIntercept' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootHelper.kt: (114, 28): Parameter 'viewTag' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (7, 44): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (14, 11): 'init(Int): Unit' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (30, 42): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (31, 21): 'receiveEvent(Int, String!, WritableMap?): Unit' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\noreanimated\src\main\java\com\swmansion\gesturehandler\ReanimatedEventDispatcher.kt: (7, 31): Parameter 'event' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\noreanimated\src\main\java\com\swmansion\gesturehandler\ReanimatedEventDispatcher.kt: (7, 41): Parameter 'reactApplicationContext' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\core\GestureHandler.kt: (755, 11): Name shadowed: size
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.kt: (9, 51): Unreachable code
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.kt: (10, 80): Unreachable code
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootHelper.kt: (77, 18): 'onChildStartedNativeGesture(MotionEvent!): Unit' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootHelper.kt: (82, 42): Parameter 'disallowIntercept' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootHelper.kt: (114, 28): Parameter 'viewTag' is never used
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (7, 44): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (14, 11): 'init(Int): Unit' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (30, 42): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: D:\Atos\MyAccess\myaccess-app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerTouchEvent.kt: (31, 21): 'receiveEvent(Int, String!, WritableMap?): Unit' is deprecated. Deprecated in Java

image

Steps to reproduce

Was working normally with react-native 0.71.7

  1. Upgraded to react-native@0.72.0 via the own upgrade command, which also changed gradle versions
  2. Ran react-native start and run on android

Snack or a link to a repository

Gesture Handler version

2.12.0

React Native version

0.72.0

Platforms

Android

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 17

Most upvoted comments

Ok. I managed to fixed mine. Previously inside my android/build.gradle, the kotlin was set to 1.5.31.

Changing to 1.6.21 seems to build fine now. Hope it help those just updated react native 0.72 having problems with building.

buildscript { ext { kotlinVersion = “1.6.21”

dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
}

in android/build.gradle change it to:

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        kotlinVersion = '1.9.0'

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
    }
}

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

‘compileDebugJavaWithJavac’ task (current target is 11) and ‘compileDebugKotlin’ task (current target is 17) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain * Try:

Use java 11 instead of 17

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

‘compileDebugJavaWithJavac’ task (current target is 11) and ‘compileDebugKotlin’ task (current target is 17) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain * Try:

Ok. I managed to fixed mine. Previously inside my android/build.gradle, the kotlin was set to 1.5.31.

Changing to 1.6.21 seems to build fine now. Hope it help those just updated react native 0.72 having problems with building.

buildscript { ext { kotlinVersion = “1.6.21”

dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
}

Thank you for sharing, @OpenTasteSG. In my case, however, we only use:

classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin")

Any ideas on what the problem could be?

With gradle set to distributionUrl=https://services.gradle.org/distributions/gradle-8.0.1-all.zip, get this error when trying to build for android

Execution failed for task ‘:tasks’.

Could not create task ‘:react-native-gesture-handler:compileDebugAndroidTestKotlin’. > Cannot use @TaskAction annotation on method AbstractKotlinCompile.execute() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method. * Try:

72.1 here and I still have this problem

React Native Version 0.72.1 fixed the issue here.

Awesome, thanks for the info, I’m gonna remove all the patch scripts 😂

Encounter the same problem. Seems only affect the android build. iOS seems to be find