我一直在我的反应本机Android应用中遇到崩溃,并带有以下呼叫stack
02-24 12:38:35.799 2878-2878/com.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 2878
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.unFocus(android.view.View)' on a null object reference
at android.view.ViewGroup.removeViewsInternal(ViewGroup.java:4300)
at android.view.ViewGroup.removeViewsInLayout(ViewGroup.java:4156)
at com.facebook.react.views.view.ReactViewGroup.updateSubviewClipStatus(ReactViewGroup.java:307)
at com.facebook.react.views.view.ReactViewGroup.updateClippingToRect(ReactViewGroup.java:283)
at com.facebook.react.views.view.ReactViewGroup.updateClippingRect(ReactViewGroup.java:276)
at com.facebook.react.views.scroll.ReactScrollView.updateClippingRect(ReactScrollView.java:220)
at com.facebook.react.views.scroll.ReactScrollView.onScrollChanged(ReactScrollView.java:152)
at android.widget.ScrollView.onOverScrolled(ScrollView.java:801)
at com.facebook.react.views.scroll.ReactScrollView.onOverScrolled(ReactScrollView.java:341)
at android.view.View.overScrollBy(View.java:18607)
at android.widget.ScrollView.computeScroll(ScrollView.java:1293)
at android.view.View.updateDisplayListIfDirty(View.java:14154)
at android.view.View.getDisplayList(View.java:14189)
at android.view.View.draw(View.java:14959)
at android.view.ViewGroup.drawChild(ViewGroup.java:3405)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.draw(View.java:15234)
at android.view.View.updateDisplayListIfDirty(View.java:14167)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279
02-24 12:38:43.283 2878-2878/com.myapp I/Process: Sending signal. PID: 2878 SIG: 9
中止是间歇性的,没有固定的步骤来复制。如果其他人在Android上经历了类似的崩溃,请分享您有更多信息。
谢谢!
这是ListView的已知问题:
将ListView的
removeClippedSubviews
设置为false
可以防止崩溃
https://github.com/facebook/react-native/issues/11825