Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Android Lists and Adapters Adapters and ViewHolders Activity

NullPointerException at holder.hourlyListItemBinding.setHour(hour);

I'm stuck I get the following error below when debugging. I don't have a good understanding of the RecyclerView which makes troubleshooting very difficult. I'm not sure where to even start.

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.stormy, PID: 11296 java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.stormy.databinding.HourlyListItemBinding.setHour(com.example.stormy.weather.Hour)' on a null object reference at com.example.stormy.adapters.HourlyAdapter.onBindViewHolder(HourlyAdapter.java:43) at com.example.stormy.adapters.HourlyAdapter.onBindViewHolder(HourlyAdapter.java:17) at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781) at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823) at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752) at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854) at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557) at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641) at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194) at android.view.View.layout(View.java:22740) at android.view.ViewGroup.layout(ViewGroup.java:6291) at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915) at android.view.View.layout(View.java:22740) at android.view.ViewGroup.layout(ViewGroup.java:6291) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22740) at android.view.ViewGroup.layout(ViewGroup.java:6291) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673) at android.widget.LinearLayout.onLayout(LinearLayout.java:1582) at android.view.View.layout(View.java:22740) at android.view.ViewGroup.layout(ViewGroup.java:6291) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22740) at android.view.ViewGroup.layout(ViewGroup.java:6291) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673) at android.widget.LinearLayout.onLayout(LinearLayout.java:1582) at android.view.View.layout(View.java:22740) at android.view.ViewGroup.layout(ViewGroup.java:6291) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at com.android.internal.policy.DecorView.onLayout(DecorView.java:776) at android.view.View.layout(View.java:22740) at android.view.ViewGroup.layout(ViewGroup.java:6291) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3402) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2879) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1906) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8089) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972) at android.view.Choreographer.doCallbacks(Choreographer.java:796) at android.view.Choreographer.doFrame(Choreographer.java:731) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957) at android.os.Handler.handleCallback(Handler.java:907) E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7478) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)