I added support for Android 14 to my app, but after that, the app crashed when invoking the onLongPress event with TouchableOpacity in release mode. The app is not crashing in debug mode.
On digging the crash with the logcat, the app was crashing with the error: Invalid Hook Call
- You might have mismatched versions of React and React DOM.
- You might be breaking the Rules of Hooks.
- You might have more than one copy of React in the same app.
I tried everything but no luck the error is still on it, please help
Stack Trace:
12-09 13:33:32.684 22511 22571 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
12-09 13:33:32.684 22511 22571 E AndroidRuntime: Process: com.autoscan.appv9, PID: 22511
12-09 13:33:32.684 22511 22571 E AndroidRuntime: com.facebook.react.common.JavascriptException: Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
12-09 13:33:32.684 22511 22571 E AndroidRuntime: 1. You might have mismatching versions of React and the renderer (such as React DOM)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: 2. You might be breaking the Rules of Hooks
12-09 13:33:32.684 22511 22571 E AndroidRuntime: 3. You might have more than one copy of React in the same app
12-09 13:33:32.684 22511 22571 E AndroidRuntime: See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem., stack:
12-09 13:33:32.684 22511 22571 E AndroidRuntime: Ur@91:41069
12-09 13:33:32.684 22511 22571 E AndroidRuntime: <unknown>@424:1218
12-09 13:33:32.684 22511 22571 E AndroidRuntime: onLongPress@915:3684
12-09 13:33:32.684 22511 22571 E AndroidRuntime: value@212:7309
12-09 13:33:32.684 22511 22571 E AndroidRuntime: value@212:6947
12-09 13:33:32.684 22511 22571 E AndroidRuntime: value@212:9161
12-09 13:33:32.684 22511 22571 E AndroidRuntime: <unknown>@212:5059
12-09 13:33:32.684 22511 22571 E AndroidRuntime: k@117:535
12-09 13:33:32.684 22511 22571 E AndroidRuntime: callTimers@117:2632
12-09 13:33:32.684 22511 22571 E AndroidRuntime: value@42:3492
12-09 13:33:32.684 22511 22571 E AndroidRuntime: <unknown>@42:747
12-09 13:33:32.684 22511 22571 E AndroidRuntime: value@42:2538
12-09 13:33:32.684 22511 22571 E AndroidRuntime: value@42:719
12-09 13:33:32.684 22511 22571 E AndroidRuntime: value@-1
12-09 13:33:32.684 22511 22571 E AndroidRuntime:
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:958)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:230)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at android.os.Looper.loop(Looper.java:319)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
12-09 13:33:32.684 22511 22571 E AndroidRuntime: at java.lang.Thread.run(Thread.java:1012)
12-09 13:33:32.713 2389 23067 W ActivityManager: crash : com.autoscan.appv9,10331
12-09 13:33:32.715 2389 3097 W ActivityTaskManager: Force finishing activity com.autoscan.appv9/.MainActivity
Package.json
{
"name": "ApexScan",
"version": "0.1.1",
"private": true,
"scripts": {
"start": "NODE_OPTIONS=--openssl-legacy-provider react-native start",
"start-cache": "react-native start --reset-cache",
"pod": "cd ios && pod install && cd ..",
"adb": "adb reverse tcp:8081 tcp:8081",
"android": "react-native run-android",
"ios": "react-native run-ios",
"startiPhone11": "npx react-native run-ios --udid 502CA678-5086-448F-B62B-8F56473E903E",
"startiPad11": "npx react-native run-ios --udid AB365004-86C5-4B5D-84DB-17EE5A4412BB",
"startiPhoneSE": "npx react-native run-ios --udid 7457F48E-DCE8-43C7-895C-C475B8AA7A84",
"ios-xed": "xed -b ios",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"createCleanReleaseAPK": "cd android && ./gradlew assembleRelease && cd .. && open ./android/app/build/outputs/apk/release",
"createCleanBundle": "cd android && ./gradlew clean && ./gradlew bundleRelease && cd .. && open ./android/app/build/outputs/bundle/release"
},
"dependencies": {
"@react-native-async-storage/async-storage": "1.15.5",
"@react-native-community/checkbox": "^0.5.8",
"@react-native-firebase/app": "^12.9.1",
"@react-native-firebase/auth": "^13.1.0",
"@react-native-google-signin/google-signin": "^7.0.1",
"@react-navigation/bottom-tabs": "5.11.11",
"@react-navigation/native": "^5.9.4",
"@react-navigation/native-stack": "6.1.0",
"@react-navigation/stack": "5.14.5",
"@reduxjs/toolkit": "1.6.1",
"@stripe/stripe-react-native": "^0.35.1",
"@types/styled-components": "5.1.11",
"@types/styled-components-react-native": "5.1.1",
"axios": "0.21.1",
"fast-xml-parser": "^3.20.3",
"geolib": "^3.3.1",
"lodash": "4.17.21",
"lottie-ios": "^3.2.3",
"lottie-react-native": "^4.1.3",
"moment": "2.29.1",
"react": "17.0.1",
"react-native": "0.66.0",
"react-native-barcode-mask": "^1.2.4",
"react-native-camera": "^4.2.1",
"react-native-currency-input": "^1.0.1",
"react-native-date-picker": "4.2.0",
"react-native-dropdown-picker": "5.1.23",
"react-native-error-boundary": "1.1.11",
"react-native-gesture-handler": "1.10.3",
"react-native-html-to-pdf": "^0.12.0",
"react-native-keyboard-aware-scroll-view": "0.9.4",
"react-native-linear-gradient": "2.5.6",
"react-native-logs": "^5.0.1",
"react-native-modal": "12.0.3",
"react-native-onesignal": "^4.5.3",
"react-native-print": "^0.11.0",
"react-native-rename": "^2.9.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^3.4.0",
"react-native-share": "^7.2.0",
"react-native-size-matters": "^0.4.2",
"react-native-smtp-mailer": "^1.2.5",
"react-native-splash-screen": "3.2.0",
"react-native-svg": "12.1.1",
"react-native-svg-transformer": "0.14.3",
"react-native-toast-message": "^1.4.9",
"react-redux": "7.2.4",
"redux": "4.1.0",
"redux-devtools-extension": "2.13.9",
"redux-logger": "3.0.6",
"redux-persist": "6.0.0",
"redux-saga": "1.1.3",
"rn-fetch-blob": "^0.12.0",
"styled-components": "5.1.1"
},
"devDependencies": {
"@babel/core": "7.12.9",
"@babel/runtime": "7.12.5",
"@react-native-community/eslint-config": "2.0.0",
"@types/jest": "26.0.23",
"@types/lodash": "4.14.172",
"@types/react-native": "0.64.5",
"@types/react-native-html-to-pdf": "^0.8.1",
"@types/react-redux": "^7.1.18",
"@types/react-test-renderer": "16.9.2",
"@types/redux-logger": "3.0.9",
"babel-jest": "26.6.3",
"eslint": "7.14.0",
"eslint-plugin-react-hooks": "^5.1.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.64.0",
"react-native-codegen": "0.0.7",
"react-test-renderer": "17.0.1",
"typescript": "^3.8.3"
},
"resolutions": {
"@types/react": "17"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}
4