Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView ViewPager java.lang.NullPointerException android.support.v7.widget.RecyclerView$ItemAnimator$ItemHolderInfo.left

I am using ViewPager with the Recyclerview, but on the creating time it crashes...

I was trying out AsyncListUtil with the Recyclerview.Adapter, and It worked. When I moved the fragment to the ViewPager it started crashing like this. Any insights ?

            FATAL EXCEPTION: main
            Process: com.dekanski.popularmovies, PID: 6554
            java.lang.NullPointerException: Attempt to read from field 'int android.support.v7.widget.RecyclerView$ItemAnimator$ItemHolderInfo.left' on a null object reference
             at android.support.v7.widget.SimpleItemAnimator.animateChange(SimpleItemAnimator.java:130)
             at android.support.v7.widget.RecyclerView.animateChange(RecyclerView.java:3062)
             at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2924)
             at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1627)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
             at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
             at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:761)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
             at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
             at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
             at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
             at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
             at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
             at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
             at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
             at android.view.View.layout(View.java:15671)
             at android.view.ViewGroup.layout(ViewGroup.java:5038)
             at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2086)
             at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1843)
             at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
             at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
             at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
             at android.view.Choreographer.doCallbacks(Choreographer.java:580)
             at android.view.Choreographer.doFrame(Choreographer.java:550)
             at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
             at android.os.Handler.handleCallback(Handler.java:739)
             at android.os.Handler.dispatchMessage(Handler.java:95)
             at android.os.Looper.loop(Looper.java:135)
             at android.app.ActivityThread.main(ActivityThread.java:5254)
             at java.lang.reflect.Method.invoke(Native Method)
             at java.lang.reflect.Method.invoke(Method.java:372)
             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
like image 629
Stefan Dekanski Avatar asked Oct 26 '15 02:10

Stefan Dekanski


3 Answers

It seems to be fixed in support version 23.2.1

like image 109
DoronK Avatar answered Oct 21 '22 18:10

DoronK


Probably this issue https://code.google.com/p/android/issues/detail?id=193958&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars#makechanges

Still happens on 23.1.1

like image 28
Artyom Shalaev Avatar answered Oct 21 '22 18:10

Artyom Shalaev


I've figured it out... I missed to include app:layout_behavior="@string/appbar_scrolling_view_behavior" to ViewPager, so CoordinatorLayout didn't know how to do it's job correctly.

like image 39
Stefan Dekanski Avatar answered Oct 21 '22 18:10

Stefan Dekanski