java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference

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

    Null pointer reference on TextView inside Adapter

    Stack Overflow | 7 months ago | Lucas Nordmeyer
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference

      at com.lucasmikesoftware.fuckaround.MyAdapter.setImageListItem()
    2. com.lucasmikesoftware.fuckaround
      MyAdapter.getView
      1. com.lucasmikesoftware.fuckaround.MyAdapter.setImageListItem(MyAdapter.java:69)
      2. com.lucasmikesoftware.fuckaround.MyAdapter.getView(MyAdapter.java:42)
      2 frames
    3. Android Platform
      View.measure
      1. android.widget.AbsListView.obtainView(AbsListView.java:2467)
      2. android.widget.ListView.measureHeightOfChildren(ListView.java:1270)
      3. android.widget.ListView.onMeasure(ListView.java:1182)
      4. android.view.View.measure(View.java:17536)
      5. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      6. android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
      7. android.view.View.measure(View.java:17536)
      7 frames
    4. Android Support v4
      ViewPager.onMeasure
      1. android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1626)
      1 frame
    5. Android Platform
      ViewGroup.measureChildWithMargins
      1. android.view.View.measure(View.java:17536)
      2. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      3. android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      4. android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      5. android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      6. android.view.View.measure(View.java:17536)
      7. android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
      8. android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
      9. android.view.View.measure(View.java:17536)
      10. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      10 frames
    6. android.support.design
      CoordinatorLayout.onMeasure
      1. android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:671)
      2. android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
      3. android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1319)
      4. android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:736)
      4 frames
    7. Android Platform
      View.measure
      1. android.view.View.measure(View.java:17536)
      1 frame
    8. Android Support v4
      DrawerLayout.onMeasure
      1. android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1079)
      1 frame
    9. Android Platform
      FrameLayout.onMeasure
      1. android.view.View.measure(View.java:17536)
      2. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      3. android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
      3 frames
    10. Android v7
      ContentFrameLayout.onMeasure
      1. android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
      1 frame
    11. Android Platform
      FrameLayout.onMeasure
      1. android.view.View.measure(View.java:17536)
      2. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      3. android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      4. android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      5. android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      6. android.view.View.measure(View.java:17536)
      7. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      8. android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
      9. android.view.View.measure(View.java:17536)
      10. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      11. android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      12. android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      13. android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      14. android.view.View.measure(View.java:17536)
      15. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5478)
      16. android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
      16 frames
    12. Android
      PhoneWindow$DecorView.onMeasure
      1. com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2629)
      1 frame
    13. Android Platform
      Choreographer.doCallbacks
      1. android.view.View.measure(View.java:17536)
      2. android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2102)
      3. android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1218)
      4. android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1435)
      5. android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1106)
      6. android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6018)
      7. android.view.Choreographer$CallbackRecord.run(Choreographer.java:792)
      8. android.view.Choreographer.doCallbacks(Choreographer.java:596)
      8 frames