Android build failure with React Native 0.81
With React Native 0.81.0, @react-native-menu/menu fails to build on Android. Gradle shows the following error messages:
> Task :react-native-menu_menu:compileDebugKotlin FAILED
[...]
e: file://[...]/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuView.kt:50:3 'setHitSlopRect' overrides nothing.
e: file://[...]/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuView.kt:51:11 Unresolved reference 'setHitSlopRect'.
e: file://[...]/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt:126:12 Unresolved reference 'setHitSlopRect'.
e: file://[...]/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt:128:12 Unresolved reference 'setHitSlopRect'.
e: file://[...]/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt:209:10 Unresolved reference 'setOverflow'.
Steps to Reproduce
- Create a new React Native project:
npx @react-native-community/cli@latest init TestProject - Go to the new project directory:
cd TestProject - Install @react-native-menu/menu:
npm install @react-native-menu/menu - Start Metro:
npx react-native start - Open a new terminal in the same directory
- Try to build the app:
npx react-native run-android
Environment Details
React Native 0.81.0 @react-native-menu/menu 1.2.4 Not using Expo or any other Framework Hermes and New Architecture enabled for Android
From android/build.gradle:
buildToolsVersion = "36.0.0"
minSdkVersion = 24
compileSdkVersion = 36
targetSdkVersion = 36
ndkVersion = "27.1.12297006"
kotlinVersion = "2.1.20"
Please let me know if you would like any more details. Thanks for looking into this!
same here
+1
@Naturalclar any chance of making this lib work with React Native 0.81?
patch for failed android build:
@react-native-menu+menu+1.2.4.patch
diff --git a/node_modules/@react-native-menu/menu/android/.DS_Store b/node_modules/@react-native-menu/menu/android/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/node_modules/@react-native-menu/menu/android/.DS_Store differ
diff --git a/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuView.kt b/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuView.kt
index 17ed7c6..c45f5cc 100644
--- a/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuView.kt
+++ b/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuView.kt
@@ -24,6 +24,11 @@ class MenuView(private val mContext: ReactContext) : ReactViewGroup(mContext) {
private var mIsOnLongPress = false
private var mGestureDetector: GestureDetector
private var mHitSlopRect: Rect? = null
+ set(value) {
+ super.hitSlopRect = value
+ mHitSlopRect = value
+ updateTouchDelegate()
+ }
init {
mGestureDetector = GestureDetector(mContext, object : GestureDetector.SimpleOnGestureListener() {
@@ -47,12 +52,6 @@ class MenuView(private val mContext: ReactContext) : ReactViewGroup(mContext) {
prepareMenu()
}
- override fun setHitSlopRect(rect: Rect?) {
- super.setHitSlopRect(rect)
- mHitSlopRect = rect
- updateTouchDelegate()
- }
-
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
return true
}
diff --git a/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt b/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt
index 4731e1a..e4d2743 100644
--- a/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt
+++ b/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt
@@ -123,9 +123,9 @@ abstract class MenuViewManagerBase : ReactClippingViewManager<MenuView>() {
fun setHitSlop(view: ReactViewGroup, @Nullable hitSlop: ReadableMap?) {
if (hitSlop == null) {
// We should keep using setters as `Val cannot be reassigned`
- view.setHitSlopRect(null)
+ view.hitSlopRect = null
} else {
- view.setHitSlopRect(
+ view.hitSlopRect = (
Rect(
if (hitSlop.hasKey("left"))
PixelUtil.toPixelFromDIP(hitSlop.getDouble("left")).toInt()
@@ -206,7 +206,7 @@ abstract class MenuViewManagerBase : ReactClippingViewManager<MenuView>() {
@ReactProp(name = ViewProps.OVERFLOW)
fun setOverflow(view: ReactViewGroup, overflow: String?) {
- view.setOverflow(overflow)
+ view.overflow = overflow
}
@ReactProp(name = "backfaceVisibility")
Thanks for this I've just tested but getting something different now.
e: file:///Users/tom/projecttest/node_modules/@react-native-menu/menu/android/src/main/java/com/reactnativemenu/MenuView.kt:50:3 Accidental override: The following declarations have the same JVM signature (setHitSlopRect(Landroid/graphics/Rect;)V):
fun `<set-hitSlopRect>`(`<set-?>`: Rect?): Unit defined in com.reactnativemenu.MenuView
fun setHitSlopRect(rect: Rect?): Unit defined in com.reactnativemenu.MenuView
FAILURE: Build failed with an exception.
you can use updated patch ( which is above your comment ). I've noticed that error late and remove and added new comment.
@omerkarakose thanks for sugestion. But after applying your patch I got the following error at line 128
view.hitSlopRect(
^^^^^^^
Expression 'hitSlopRect' of type 'Rect?' cannot be invoked as a function. Function 'invoke()' is not found.
that patch worked for me for the latest version which is:
"@react-native-menu/menu": "1.2.4",
Confirm that @omerkarakose's shared patch resolved the issue for me. The issue surfaced when I upgraded Expo from SDK 53 to SDK 54.
i found similar issue for 2.0.0 and react native 0.77/0.78
ext { buildToolsVersion = "35.0.0" minSdkVersion = 26 compileSdkVersion = 35 targetSdkVersion = 34 ndkVersion = "27.1.12297006" kotlinVersion = "2.0.21" }
Execution failed for task ':react-native-menu_menu:compileDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details * Try:
anybody has idea? Ty
i found similar issue for 2.0.0 and react native 0.77/0.78
ext { buildToolsVersion = "35.0.0" minSdkVersion = 26 compileSdkVersion = 35 targetSdkVersion = 34 ndkVersion = "27.1.12297006" kotlinVersion = "2.0.21" }Execution failed for task ':react-native-menu_menu:compileDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details * Try:
anybody has idea? Ty
https://github.com/react-native-menu/menu/issues/1186