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

Stack Overflow | Wai Yan Hein | 4 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    cannot set colors resource for Color Preference picker Android

    Stack Overflow | 4 months ago | Wai Yan Hein
    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

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

      at memegenerator.waiyanhein.com.adapter.InstalledTemplatesAdapter.getItemCount()
    2. memegenerator.waiyanhein.com
      InstalledTemplatesAdapter.getItemCount
      1. memegenerator.waiyanhein.com.adapter.InstalledTemplatesAdapter.getItemCount(InstalledTemplatesAdapter.java:92)
      1 frame
    3. Android v7
      RecyclerView.onLayout
      1. android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:2938)
      2. android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2904)
      3. android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283)
      3 frames
    4. Android Platform
      ViewGroup.layout
      1. android.view.View.layout(View.java:16636)
      2. android.view.ViewGroup.layout(ViewGroup.java:5437)
      3. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
      4. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
      5. android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
      6. android.view.View.layout(View.java:16636)
      7. android.view.ViewGroup.layout(ViewGroup.java:5437)
      7 frames
    5. Android Support v4
      ViewPager.onLayout
      1. android.support.v4.view.ViewPager.onLayout(ViewPager.java:1695)
      1 frame
    6. Android Platform
      FrameLayout.onLayout
      1. android.view.View.layout(View.java:16636)
      2. android.view.ViewGroup.layout(ViewGroup.java:5437)
      3. android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
      4. android.view.View.layout(View.java:16636)
      5. android.view.ViewGroup.layout(ViewGroup.java:5437)
      6. android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
      7. android.widget.FrameLayout.onLayout(FrameLayout.java:273)
      8. android.view.View.layout(View.java:16636)
      9. android.view.ViewGroup.layout(ViewGroup.java:5437)
      10. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
      11. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
      12. android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
      13. android.view.View.layout(View.java:16636)
      14. android.view.ViewGroup.layout(ViewGroup.java:5437)
      15. android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
      16. android.widget.FrameLayout.onLayout(FrameLayout.java:273)
      17. android.view.View.layout(View.java:16636)
      18. android.view.ViewGroup.layout(ViewGroup.java:5437)
      19. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
      20. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
      21. android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
      22. android.view.View.layout(View.java:16636)
      23. android.view.ViewGroup.layout(ViewGroup.java:5437)
      24. android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
      25. android.widget.FrameLayout.onLayout(FrameLayout.java:273)
      25 frames
    7. Android
      PhoneWindow$DecorView.onLayout
      1. com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
      1 frame
    8. Android Platform
      ActivityThread.main
      1. android.view.View.layout(View.java:16636)
      2. android.view.ViewGroup.layout(ViewGroup.java:5437)
      3. android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
      4. android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
      5. android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
      6. android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
      7. android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
      8. android.view.Choreographer.doCallbacks(Choreographer.java:670)
      9. android.view.Choreographer.doFrame(Choreographer.java:606)
      10. android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
      11. android.os.Handler.handleCallback(Handler.java:739)
      12. android.os.Handler.dispatchMessage(Handler.java:95)
      13. android.os.Looper.loop(Looper.java:148)
      14. android.app.ActivityThread.main(ActivityThread.java:5417)
      14 frames
    9. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      1 frame
    10. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
      2 frames