React-native: java.lang.Double.doubleValue()' on a null object reference

Created on 23 May 2018  路  31Comments  路  Source: facebook/react-native

Received this to Crashlytics. RN does not provide any information, which would help to find the cause of this (unless it is actually a bug in RN).

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
       at com.facebook.react.bridge.ReadableNativeArray.getDouble(ReadableNativeArray.java:114)
       at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:64)
       at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:60)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:359)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:789)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
       at android.os.Looper.loop(Looper.java:164)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
       at java.lang.Thread.run(Thread.java:764)
Ran Commands For Stack Overflow Locked

Most helpful comment

This error happened to me when I used a bridge in the wrong way, causing the error, for example, to use the toastAndroid.show ('....') without passing the time

All 31 comments


It looks like your issue may be incomplete. Are all the fields required by the Issue Template filled out?

If you believe your issue contains all the relevant information, let us know in order to have a maintainer remove the No Template label.

Please use Stack Overflow for this type of question.

I am also facing this issue in production.

This is a React Native issue. It has something to do with the bridge, state changes and updating the UI. I changed the order in which I set the state an call native methods and the error does not occur anymore.

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1. @tapz, to clarify are you referring to redux state? Could you supply more specifics on your fix please?

Nevermind, seems to be more discussion on this in #19423. Would be awesome to understand more details of your fix there.

@seanmorton Obsiously, I'm referring to React Component (local) state, which makes the component to update.

Thanks for the clarification!

I "fixed" the problem by making sure status bar color in ReactNative same as the status bar color in Android theme

+1

This error happened to me when I used a bridge in the wrong way, causing the error, for example, to use the toastAndroid.show ('....') without passing the time

I have this error when I pass NaN to animatedScale.setValue(newScale). If anyone else is experiencing this issue during animation handling, check your calculation so that new value always should be a real number.

guys how are you debugging such crashes? is there a way to catch native errors?

the second param must be a Double or Int , not a String
try ToastExample.show('Awesome',300);
it worked for me

i solved it in react native with redux and problem was related to style of store new state for redux ...

for this bug you must first get instance of state in redux reducer like this ::

const newState = state;

and then change and return it::

newState.check = true;

return newState;

bug did fix for me after 24 hours trying ...

This error happened to me when I used a bridge in the wrong way, causing the error, for example, to use the toastAndroid.show ('....') without passing the time

That was my mistake, I forgot the duration for the ToastAndroid.show()

I'm facing this error on android, after upgrade to RN 0.58.2 ... Any help?

I'm facing this error on android, after upgrade to RN 0.58.2 ... Any help?

For me the issue was using <StatusBar barStyle={"dark-content"} animated={true} /> in render method. It seems that now you need to provide backgroundColor and hidden props as well or it will crash.
But using imperative API it works as previously:

componentDidMount() {
  StatusBar.setBarStyle(...);
}

I also raised an issue (https://github.com/facebook/react-native/issues/23193).

@abendi, make sense. Matter fact, I'm using <StatusBar .. /> too. I'll double check it.. The community are fixing it. They will release 0.58.3 less than a couple hours.

Also facing a similar one to this using Axios, did somebody fixed or found a work around for this?

[edit]

It was raised by axios, but giving it a timeout (like 500) in it's own config fixed the issue. Weird.

+1

My Envirment:
React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz
Memory: 5.13 GB / 15.94 GB
Binaries:
Yarn: 1.16.0 - C:Program Files (x86)Yarnbinyarn.CMD
npm: 6.1.0 - C:Program Filesnodejsnpm.CMD
IDEs:
Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338

I have got this problem too!
When this error happend, I tried rollbacking my codebase to the production branch, but the compiled debug version still got this problem!

After half-day debugging, I thoungt that when the first time this bug occur, I ran react-native run-android and the logs said that gradle was downloading some files but stucked! (Network issue?) Then I ctrl-C to run again react-native run-android, this problem happened!

So I delete all the cache files/dirs in home/.gradle/cache (On windows, it's %USERPROFILE%.gradlecache) and run react-native run-android again, this bug gone away!

Good Luck!

Was this page helpful?
0 / 5 - 0 ratings