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.

Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference

See original GitHub issue

This native code exception occured when I was extracting Gesture Handlers into a component.

Compare this:

function ThisWorks() {
  return (
    <TapGestureHandler>
      <MyView/>
    </TapGestureHandler>
  )
}

to this:

function ThisCrashes() {
  return (
    <MyTapHandler>
      <MyView/>
    </MyTapHandler>
  )
}

function MyTapHandler({children}) {
  return (
    <TapGestureHandler>
      {children}
    </TapGestureHandler>
  )
}

This problem might be related to the fact that children is internally an array of components (even if the length is 1), it can be worked around by wrapping it into a <View>:

function MyTapHandlerFixed({children}) {
  return (
    <TapGestureHandler>
      <View>{children}</View>
    </TapGestureHandler>
  )
}

Usually, when I add multiple children to a GestureHandler, I’m getting this error from the library: Invariant Violation: React.Children.only expected to receive a single React element child.

This error does not occur when the value is passed as the {children} prop as described above. Instead, a hard to debug native exception occured. Not sure if this is an error of react-native-gesture-handler or of react-native itself, but I wanted to post here to give a heads-up to other people who might encounter this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:22
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anabeatrizzzcommented, Aug 31, 2021

@peritus I’m having the same issue with RefreshControl EDIT: This comment helped me: https://github.com/software-mansion/react-native-gesture-handler/issues/1067#issuecomment-724688373

0reactions
piaskowykcommented, Mar 31, 2022

Hey, I have just tested it on 1.10.2 and it seems to work, so could you update the version of the gesture handler and let me know if It works for you?

In this thread, I can see another issue related to RefreshControl but this thread should be continued here: https://github.com/software-mansion/react-native-gesture-handler/issues/1067

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error on "Attempt to invoke virtual method 'double java.lang ...
Your latitude and longitude are NULL, as they are only declared and value never assigned. Example : latitude=28.6139391;.
Read more >
Attempt to invoke virtual method 'double java.lang ... - GitHub
Attempt to invoke virtual method 'double java.lang.Double.doubleValue() #23126 ... doubleValue()' on a null object reference #26806.
Read more >
attempt to invoke virtual method 'double java.lang ... - You.com
Android- Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference. Asked Dec 2, 2017 • 1 votes 2 answers.
Read more >
Java.lang.Double.doubleValue() Method - Tutorialspoint
The java.lang.Double.doubleValue() method returns the double value of this Double object. Declaration. Following is the declaration for java.lang.Double ...
Read more >
"Cannot invoke "java.lang.Double.doubleValue()" " error
Hello everyone! It seems like my files cannot be recognised(?) anymore. Actually when I try to type a specific number for the thresholder ......
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