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.

Crash: null object reference on init

See original GitHub issue

Hey,

We’re seeing the crashes using latest beta (with RN 0.51.1). Seems to be a race condition on init, let me know if you need more info. Using .beta8.

This code crashes:

class App extends React.Component<{}> {
  render() {
    return (
      <CoordinatorLayout style={{flex: 1}}>
        <BottomSheetBehavior
          peekHeight={70}
          hideable={false}
          state={BottomSheetBehavior.STATE_COLLAPSED}
        >
          <View style={{backgroundColor: '#4389f2'}}>
            <View style={{padding: 26}}>
              <Text>BottomSheetBehavior!</Text>
            </View>
            <View style={{height: 200, backgroundColor: '#fff'}} />
          </View>
        </BottomSheetBehavior>
      </CoordinatorLayout>
    );
  }
}

export default App;

This code works:

class App extends React.Component<{}> {
  constructor() {
    super();
    this.state = {
      ok: false,
    }
  }

  componentDidMount() {
    setTimeout(() => this.setState({ok: true}), 5000);
  }

  render() {
    return (
      <CoordinatorLayout style={{flex: 1}}>
        {this.state.ok && (
          <BottomSheetBehavior
            peekHeight={70}
            hideable={false}
            state={BottomSheetBehavior.STATE_COLLAPSED}
          >
            <View style={{backgroundColor: '#4389f2'}}>
              <View style={{padding: 26}}>
                <Text>BottomSheetBehavior!</Text>
              </View>
              <View style={{height: 200, backgroundColor: '#fff'}} />
            </View>
          </BottomSheetBehavior>
        )}
      </CoordinatorLayout>
    );
  }
}

Stack:

Attempt to invoke virtual method 'void android.support.v4.widget.ViewDragHelper.process TouhEnvent(android.view.MotionEvent)' on a null object reference

onTouchEvent
RnBottomSheetBehavior.java:273

resetTouchBehaviors
CoordinatorLayout.java:396

onAttachedToWindow
CoordinatorLayout.java:238

dispatchAttachedToWindow
View.java:16638

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cesardeazevedocommented, Jul 6, 2018

Shipped at 1.0.0

1reaction
cesardeazevedocommented, Jul 6, 2018

I’ve successfully reproduced your problem when i compiled with 27, i applied @FlorianBergmann patch and worked.

i will make a new release soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Null Object Reference: Application Crashing - Stack Overflow
I am having problems with my application as it always crash but I'm unsure of how to go about fixing it. Any help...
Read more >
Crash in java.lang.NullPointerException - Bugzilla@Mozilla
Crash in java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.view.View.getContext()' on a null object reference at ...
Read more >
Crash in ListView (Null object reference)
My app crashed and this is the logcat output. It appears to be an issue in the ListView item selection code. Hmm.
Read more >
Null Reference Exceptions - Unity - Manual
NullReferenceException happens when your script code tries to use a variable which isn't set (referencing) and object. The error message that appears tells...
Read more >
Crashes | Android Developers
As a best practice, make sure you address the null case for a nullable object, or your app could get into unexpected states....
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