question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnexpectedNativeTypeException: Value for message cannot be cast from ReadableNativeMap to String

See original GitHub issue

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native
  • react-native-sentry

react-native version: 0.60.5

Init Code:

Sentry.init({
  dsn: Config.SENTRY_DSN,
  environment: process.env.NODE_ENV || 'development'
});

I have following issue:

As soon as I call init on the Sentry SDK my app crashes with UnexpectedNativeTypeException: Value for message cannot be cast from ReadableNativeMap to String. Though this only happens on Android and not on iOS.

This issue was reported in the beta as well: https://github.com/getsentry/sentry-react-native/issues/612#issuecomment-524264131

and #651 also seems related:

react-native info

info Fetching system and libraries information...
System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
    Memory: 105.25 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.9.1 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.10.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: ^16.9.0 => 16.9.0 
    react-native: ^0.60.5 => 0.60.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1

screenshot: image

stacktrace in logcat:

09-05 13:56:09.528  7448  7530 E unknown:ReactNative: Exception in native call
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: com.facebook.react.bridge.UnexpectedNativeTypeException: Value for message cannot be cast from ReadableNativeMap to String
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.ReadableNativeMap.checkInstance(ReadableNativeMap.java:141)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.ReadableNativeMap.getNullableValue(ReadableNativeMap.java:129)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.ReadableNativeMap.getString(ReadableNativeMap.java:163)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at io.sentry.RNSentryModule.sendEvent(RNSentryModule.java:209)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at java.lang.reflect.Method.invoke(Native Method)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at android.os.Handler.handleCallback(Handler.java:873)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at android.os.Looper.loop(Looper.java:193)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
09-05 13:56:09.528  7448  7530 E unknown:ReactNative: 	at java.lang.Thread.run(Thread.java:764)

Steps to reproduce:

  • call init on react-native 0.60.5 with @sentry/react-native 1.0.4

Actual result:

  • App crashes with UnexpectedNativeTypeException

Expected result:

  • SDK is set up successfully

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mikeRChambers610commented, Jun 19, 2021

what is the fix…?

1reaction
HazATcommented, Sep 5, 2019

OK, I know how to fix this error but I want to understand how this happens. So there is no other place in your codebase where you have any calls to Sentry.*?

The error message clearly says that the value of event.message is not a string.

Edit: logLevel is not longer support in the options, maybe this triggers an error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Value for title can not be cast from ReadablenativeMap to string
This error was fixed when the code changed from: Alert.alert('Error:', error). to: Alert.alert('Error:', error.message).
Read more >
Value for title can not be cast from ReadablenativeMap to string
iOS : Value for title can not be cast from ReadablenativeMap to string [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >
value for message cannot be cast from readablenativearray to ...
I keep getting this error on my react native application. Fatal Exception: java.lang.ClassCastException: Value for message cannot be cast from ReadableNativeMap ...
Read more >
[Solved]-Set value from string to number-React Native
Coding example for the question Set value from string to number-React Native. ... Value for message cannot be cast from ReadableNativeMap to String...
Read more >
ReadableNativeMap cannot be cast to java.lang.String #851
finishTransaction crashes: ReadableNativeMap cannot be cast to java.lang.String #851. voxspox posted onGitHub. Version of react-native-iap.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found