java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference

Stack Overflow | pavithra | 3 months ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael and poroszd . Or join the community to write better ones.
  1. 0
    samebug tip
    If you're using notifyItemChanged(position) try changing it for notifyDataSetChanged(). This could be a bug with notifyItemChanged. Try dispatching all events as soon as they happen as well, since RecyclerView already bundles the updates by default.
  2. 0
    samebug tip
    This issue was solved in 2.2.6. If updating doesn't solve, try using notifyItemRangeChanged(1, mDatas.size()) instead of notifyItemRangeChanged(0, mDatas.size()).
  3. 0
    samebug tip
    Also, you should dispatch events as soon as they happen, ReciclerView already bundles all updates.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    samebug tip
    You have to provide valid identical number for each child items.
    via GitHub by h6ah4i
  6. 0
    samebug tip
    This happens when you have android:animateLayoutChanges set to true in your XML file and you call notifyDataSetChanged(). To fix it, you have to set android:animateLayoutChanges to false.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke interface method 'int java.util.List.size()' on a null object reference

      at info.sherpify.pavithracs.sherpifys.adapter.RecyclerViewAdapterSearch.getItemCount()
    2. info.sherpify.pavithracs
      RecyclerViewAdapterSearch.getItemCount
      1. info.sherpify.pavithracs.sherpifys.adapter.RecyclerViewAdapterSearch.getItemCount(RecyclerViewAdapterSearch.java:85)
      1 frame
    3. Android v7
      RecyclerView.onLayout
      1. android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3289)
      2. android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3186)
      3. android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3632)
      3 frames
    4. Android Platform
      ViewGroup.layout
      1. android.view.View.layout(View.java:15689)
      2. android.view.ViewGroup.layout(ViewGroup.java:5040)
      2 frames
    5. Android Support v4
      SwipeRefreshLayout.onLayout
      1. android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:636)
      1 frame
    6. Android Platform
      ActivityThread.main
      1. android.view.View.layout(View.java:15689)
      2. android.view.ViewGroup.layout(ViewGroup.java:5040)
      3. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
      4. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
      5. android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
      6. android.view.View.layout(View.java:15689)
      7. android.view.ViewGroup.layout(ViewGroup.java:5040)
      8. android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
      9. android.widget.FrameLayout.onLayout(FrameLayout.java:514)
      10. android.view.View.layout(View.java:15689)
      11. android.view.ViewGroup.layout(ViewGroup.java:5040)
      12. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
      13. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
      14. android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
      15. android.view.View.layout(View.java:15689)
      16. android.view.ViewGroup.layout(ViewGroup.java:5040)
      17. android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
      18. android.widget.FrameLayout.onLayout(FrameLayout.java:514)
      19. android.view.View.layout(View.java:15689)
      20. android.view.ViewGroup.layout(ViewGroup.java:5040)
      21. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
      22. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
      23. android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
      24. android.view.View.layout(View.java:15689)
      25. android.view.ViewGroup.layout(ViewGroup.java:5040)
      26. android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
      27. android.widget.FrameLayout.onLayout(FrameLayout.java:514)
      28. android.view.View.layout(View.java:15689)
      29. android.view.ViewGroup.layout(ViewGroup.java:5040)
      30. android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2116)
      31. android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
      32. android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
      33. android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
      34. android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
      35. android.view.Choreographer.doCallbacks(Choreographer.java:580)
      36. android.view.Choreographer.doFrame(Choreographer.java:550)
      37. android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
      38. android.os.Handler.handleCallback(Handler.java:739)
      39. android.os.Handler.dispatchMessage(Handler.java:95)
      40. android.os.Looper.loop(Looper.java:135)
      41. android.app.ActivityThread.main(ActivityThread.java:5343)
      41 frames
    7. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    8. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
      2 frames