I am getting this error on Recyclerview
in production
, but don't know exactly in which class
What I did
Google it and found https://issuetracker.google.com/issues/38375597 , where people said its android bug and fixed in support lib 27.1.0
I updated my support lib and buildVersion
support : '27.1.0',
buildToolsVersion: '27.0.3',
compileSdkVersion : 26,
Still this crash occurrs
error log
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.GapWorker.remove(android.support.v7.widget.RecyclerView)' on a null object reference
at android.support.v7.widget.RecyclerView.onDetachedFromWindow(RecyclerView.java:2534)
at android.view.View.dispatchDetachedFromWindow(View.java:13586)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2849)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2846)
at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3076)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5709)
at android.view.ViewRootImpl.die(ViewRootImpl.java:5686)
at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:387)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:342)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:116)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3893)
at android.app.ActivityThread.access$1500(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:159)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
This issue usually occurs when no LayoutManager
was provided for the RecyclerView
. You can do it like so
final LinearLayoutManager layoutManager = new LinearLayoutManager(context);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With