Skip to content

[Android] compileReleaseKotlin fails on RN < 0.74 since 1.21.0: Unresolved reference ClippingScrollViewDecoratorViewManager (wrong package declaration) #1585

Description

@ahulterstrom

Describe the bug

Android release builds fail on React Native < 0.74 (old architecture) since v1.21.0:

> Task :react-native-keyboard-controller:compileReleaseKotlin FAILED

e: .../android/src/turbo/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt:63:7
   Unresolved reference: ClippingScrollViewDecoratorViewManager

Root cause

ClippingScrollViewDecoratorViewManager.kt in both the paper and fabric source sets declares:

package java.com.reactnativekeyboardcontroller

instead of package com.reactnativekeyboardcontroller — it looks like the java/ source-root folder got baked into the package name when the file was created. Every other file in the library is in com.reactnativekeyboardcontroller.

The base variant of KeyboardControllerPackage.kt (used when RN >= 0.74) compensates with an explicit import, so most users never hit this:

import java.com.reactnativekeyboardcontroller.ClippingScrollViewDecoratorViewManager

But the turbo variant (compiled when shouldUseBaseReactPackage() is false, i.e. RN < 0.74) references the class unqualified with no import, so it only resolves if the class is in com.reactnativekeyboardcontroller — which it isn't. Hence the compile failure on every RN < 0.74 build since the component was introduced in 1.21.0. Still present on main as of today.

Suggested fix

Rename the package in android/src/paper/.../ClippingScrollViewDecoratorViewManager.kt and android/src/fabric/.../ClippingScrollViewDecoratorViewManager.kt to com.reactnativekeyboardcontroller, and drop the java.com. import from the base KeyboardControllerPackage.kt. (As a side benefit, that moves the class out of the java.* namespace, which is prohibited on the JVM ClassLoader and only works on Android because classes load from dex.)

To Reproduce

  1. RN 0.72.x app, old architecture (newArchEnabled=false)
  2. Install react-native-keyboard-controller >= 1.21.0
  3. cd android && ./gradlew :react-native-keyboard-controller:compileReleaseKotlin
  4. Compilation fails with the unresolved reference above

Expected behavior

The library compiles on all RN versions it supports.

Workaround

patch-package adding the same import line the base variant uses to android/src/turbo/.../KeyboardControllerPackage.kt:

 import com.reactnativekeyboardcontroller.modules.statusbar.StatusBarManagerCompatModuleImpl
+import java.com.reactnativekeyboardcontroller.ClippingScrollViewDecoratorViewManager

Environment

  • Desktop OS: macOS 15 / ubuntu-latest CI
  • RN version: 0.72.3
  • RN architecture: old/paper
  • JS engine: Hermes
  • Library version: 1.22.3 (affects 1.21.0 through 1.22.3 and current main)

Metadata

Metadata

Assignees

Labels

build error ❌Anything that triggers build errors and prevent this library from being used🤖 androidAndroid specific

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions