Skip to content

Android: Kotlin 2.3 compile error in RNGestureHandlerModule (rootViewTag vs getRootViewTag) #4042

Closed

Description

@christian-apollo

Summary

When compiling the Android library with Kotlin 2.3.x (e.g. as required by other dependencies such as Stripe Android SDK), RNGestureHandlerModule.kt fails to compile in findRootHelperForViewAncestor:

Function invocation 'getRootViewTag()' expected

at the expression using it.rootView.rootViewTag next to a local variable also named rootViewTag.

Environment

  • react-native-gesture-handler 2.30.1 (also reproducible on current 2.30.x line)
  • Kotlin 2.3.0+ (project/toolchain aligned with RN 0.83 + libraries compiled with Kotlin 2.3 metadata)
  • Android Gradle Plugin 8.12 (typical RN 0.83 setup)

Root cause

Inside findRootHelperForViewAncestor, the local val rootViewTag = ... shadows the synthetic Kotlin property rootViewTag on ReactRootView. The compiler then fails to resolve the property access on the left-hand side of the comparison (Kotlin 2.3 is stricter here than 2.1.x).

ReactRootView exposes the tag via getRootViewTag() in Java; the fix is to use an explicit receiver and call getRootViewTag() (or rename the local variable).

Suggested fix

synchronized(roots) {
  return roots.firstOrNull {
    val rv = it.rootView
    rv is ReactRootView && rv.getRootViewTag() == rootViewTag
  }
}

Workaround

Consumers can apply the one-line change locally (e.g. patch-package) until an upstream release includes the fix.


Related downstream context: projects that bump Kotlin to 2.3 for Stripe or other SDKs hit this as a hard compile failure on :react-native-gesture-handler:compileDebugKotlin.

Activity

  1. github-actions commented on Mar 27, 2026

    @github-actions

    Hey! 👋

    It looks like you've omitted a few important sections from the issue template.

    Please complete Description, Steps to reproduce, A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug., Gesture Handler version, React Native version and Platforms sections.

  2. github-actions commented on Mar 27, 2026

    @github-actions

    Hey! 👋

    The issue doesn't seem to contain a minimal reproduction.

    Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

  3. christian-apollo commented on Mar 27, 2026

    @christian-apollo
    Author

    Opened PR with the fix: #4043 (target branch 2.30-stable).

  4. added a commit that references this issue on Apr 2, 2026
    7bf8b07
  5. m-bert commented on Apr 2, 2026

    @m-bert
    Collaborator

    Released in 2.31.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions