Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native release build crash issue, but on debug it is working fine

I am facing the release build crash issue on iOS and getting the below error:

[error][tid:com.facebook.react.JavaScript] ReferenceError: Can't find variable: typeAnnotation
2020-12-31 01:16:15.086 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: ReferenceError: Can't find variable: typeAnnotation
2020-12-31 01:16:15.125896+0530 EPG[11841:95064] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: ReferenceError: Can't find variable: typeAnnotation', reason: 'Unhandled JS Exception: ReferenceError: Can't find variable: typeAnnotation, stack:
<unknown>@1064:17089
v@2:1474
<unknown>@1063:426
v@2:1474
<unknown>@1062:340
v@2:1474
<unknown>@1055:6339
v@2:1474
<unknown>@1054:156
v@2:1474
<unknown>@1053:229
v@2:1474
<unknown>@1051:167
v@2:1474
<unknown>@847:284
v@2:1474
<unknown>@846:211
v@2:1474
<unknown>@442:454
v@2:1474
<unknown>@413:400
v@2:1474
<unknown>@412:138
v@2:1474
<unknown>@6:61
v@2:1474
d@2:876
global code@1935:4
'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001108b0e6e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x000000010fb779b2 objc_exception_throw + 48
    2   EPG                                 0x000000010a3f6f05 RCTFormatError + 0
    3   EPG                                 0x000000010a46c11c -[RCTExceptionsManager reportFatalException:stack:exceptionId:] + 508
    4   CoreFoundation                      0x00000001108b7dec __invoking___ + 140
    5   CoreFoundation                      0x00000001108b4fd1 -[NSInvocation invoke] + 321
    6   CoreFoundation                      0x00000001108b52a4 -[NSInvocation invokeWithTarget:] + 68
    7   EPG                                 0x000000010a42ab0a -[RCTModuleMethod invokeWithBridge:module:arguments:] + 578
    8   EPG                                 0x000000010a42cd94 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 246
    9   EPG                                 0x000000010a42cb1c ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 78
    10  libdispatch.dylib                   0x00000001139daf11 _dispatch_call_block_and_release + 12
    11  libdispatch.dylib                   0x00000001139dbe8e _dispatch_client_callout + 8
    12  libdispatch.dylib                   0x00000001139e26fd _dispatch_lane_serial_drain + 788
    13  libdispatch.dylib                   0x00000001139e328f _dispatch_lane_invoke + 422
    14  libdispatch.dylib                   0x00000001139eeb65 _dispatch_workloop_worker_thread + 719
    15  libsystem_pthread.dylib             0x00007fff52301a3d _pthread_wqthread + 290
    16  libsystem_pthread.dylib             0x00007fff52300b77 start_wqthread + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Do any one has idea that what might cause and issue like this, i am having the version of react-native as "react-native": "^0.61.2" and my package. json looks like:

{
  "name": "My App",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "1.8.1",
    "@react-native-community/datetimepicker": "3.0.8",
    "@react-native-community/push-notification-ios": "1.1.0",
    "@react-native-firebase/analytics": "6.7.1",
    "@react-native-firebase/app": "6.7.1",
    "@react-native-firebase/messaging": "6.7.1",
    "base64url": "3.0.1",
    "i18n-js": "3.5.1",
    "lodash": "4.17.15",
    "moment": "2.24.0",
    "native-base": "2.13.12",
    "react": "16.9.0",
    "react-native": "^0.61.2",
    "react-native-camera": "3.21.0",
    "react-native-collapsible": "1.5.2",
    "react-native-color-picker": "0.6.0",
    "react-native-config": "0.12.0",
    "react-native-dash": "0.0.11",
    "react-native-document-picker": "3.3.2",
    "react-native-easy-grid": "0.2.2",
    "react-native-geocoding": "0.4.0",
    "react-native-image-picker": "1.1.0",
    "react-native-image-resizer": "1.2.1",
    "react-native-keyboard-aware-scrollview": "2.1.0",
    "react-native-linear-gradient": "2.5.6",
    "react-native-localize": "1.3.4",
    "react-native-maps": "0.26.1",
    "react-native-navigation": "3.7.0",
    "react-native-open-maps": "0.3.5",
    "react-native-pdf": "6.1.0",
    "react-native-picker-select": "6.6.0",
    "react-native-print": "0.6.0",
    "react-native-push-notification": "3.1.9",
    "react-native-ratings": "6.5.0",
    "react-native-restart": "0.0.13",
    "react-native-share": "3.1.2",
    "react-native-ssl-pinning": "1.4.5",
    "react-native-tag-input": "0.0.21",
    "react-native-webview": "7.6.0",
    "react-redux": "7.2.0",
    "redux": "4.0.5",
    "redux-thunk": "2.3.0",
    "rn-fetch-blob": "0.12.0",
    "rn-secure-storage": "2.0.4"
  },
  "devDependencies": {
    "@babel/core": "7.9.0",
    "@babel/runtime": "7.12.5",
    "@react-native-community/eslint-config": "0.0.5",
    "babel-jest": "24.9.0",
    "eslint": "6.8.0",
    "jest": "24.9.0",
    "metro-react-native-babel-preset": "0.56.4",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

I already tried it by uninstalling the node_modules and doing the pod install many times, but not having getting it fixed with any solution.

Help will be highly appreciated. Thanks in advance.

like image 1000
Anshul Avatar asked Dec 30 '20 20:12

Anshul


People also ask

How do I know if I have crash in react native?

If you want to check your crashes in your debug mode then you can enable it by creating a firebase. json file at the root of your project. Crashlytics is disabled by default for debug mode. After a successful crash, you can see results on the Crashlytics section in the firebase console.

What is the difference between debug and non-debug JS engine in React Native?

recently, I detected that JS engine in react native non-debug mode is different than the one in debug mode, because in debug mode, your code runs in chrome V8 engine but in none-debug mode, it runs in JavaScriptCore embedded in your devices. so some feature does not work well in non-debug mode like some of date function ,etc.

Why am I getting ‘duplicate resources’ error in React Native?

Now if you will try to build the project you may get ‘ Duplicate resources ’ errors. Reason behind this is when we run react-native bundle command it generate few drawable folder inside android project’s res ( [project_root]/android/app/src/main/res)folder.

Why is React-Native-gesture-handler not working in release build?

Currently react-native-gesture-handler has to be imported before everything for the release build to work without crashing. Then try to clean and rebuild the release again. Show activity on this post. as some of the classes/functions/methods might be ignored and not included in the release build if the compiler thinks its not used.

Does react-native-gesture-handler need to be imported before everything?

Currently react-native-gesture-handler has to be imported before everything for the release build to work without crashing. Then try to clean and rebuild the release again. Show activity on this post.


Video Answer


2 Answers

I solve this yesterday, try looking in your code for something like @babel/types for me, it was to remove import { identifier } from '@babel/types'; – aharon vishinsky

Thank you aharon vishinsky -- it is very helpful for me.

like image 105
Vijay Chowdary Avatar answered Oct 21 '22 15:10

Vijay Chowdary


For my case: The vscode plugin "Auto import" seem insert a "import" statement:

import { OBJECTMEMBER_TYPES } from '@babel/types';

So, just delete it, then you should be ok.

like image 20
Liang Avatar answered Oct 21 '22 16:10

Liang