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
- RN 0.72.x app, old architecture (
newArchEnabled=false)
- Install
react-native-keyboard-controller >= 1.21.0
cd android && ./gradlew :react-native-keyboard-controller:compileReleaseKotlin
- 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)
Describe the bug
Android release builds fail on React Native < 0.74 (old architecture) since v1.21.0:
Root cause
ClippingScrollViewDecoratorViewManager.ktin both thepaperandfabricsource sets declares:instead of
package com.reactnativekeyboardcontroller— it looks like thejava/source-root folder got baked into the package name when the file was created. Every other file in the library is incom.reactnativekeyboardcontroller.The
basevariant ofKeyboardControllerPackage.kt(used when RN >= 0.74) compensates with an explicit import, so most users never hit this:But the
turbovariant (compiled whenshouldUseBaseReactPackage()is false, i.e. RN < 0.74) references the class unqualified with no import, so it only resolves if the class is incom.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 onmainas of today.Suggested fix
Rename the package in
android/src/paper/.../ClippingScrollViewDecoratorViewManager.ktandandroid/src/fabric/.../ClippingScrollViewDecoratorViewManager.kttocom.reactnativekeyboardcontroller, and drop thejava.com.import from thebaseKeyboardControllerPackage.kt. (As a side benefit, that moves the class out of thejava.*namespace, which is prohibited on the JVM ClassLoader and only works on Android because classes load from dex.)To Reproduce
newArchEnabled=false)react-native-keyboard-controller>= 1.21.0cd android && ./gradlew :react-native-keyboard-controller:compileReleaseKotlinExpected behavior
The library compiles on all RN versions it supports.
Workaround
patch-package adding the same import line the
basevariant uses toandroid/src/turbo/.../KeyboardControllerPackage.kt:import com.reactnativekeyboardcontroller.modules.statusbar.StatusBarManagerCompatModuleImpl +import java.com.reactnativekeyboardcontroller.ClippingScrollViewDecoratorViewManagerEnvironment
main)