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.
Jakob Wozniak17,896 Points
FATAL EXCEPTION: main
Hi everybody! I just spent a good chunk of time trying to figure out this error I was getting, so I thought I'd share the answer and the technique for finding it. My app kept shutting down when I tapped the 7 DAY VIEW button, and I'd get this long error:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference at android.widget.AbsListView.obtainView(AbsListView.java:2363) at android.widget.ListView.makeAndAddView(ListView.java:1875) at android.widget.ListView.fillDown(ListView.java:702) at android.widget.ListView.fillFromTop(ListView.java:763) at android.widget.ListView.layoutChildren(ListView.java:1684)
It goes on and on. I tried checking all the answers here for the video, but no one seemed to have this same problem. I googled the first part of the error (through "on a null object reference at android.widget"), and found a StackTrace post about it.
Turns out, I was returning null on my "public View getView" method in the DayAdapter, and all I needed was to change it to return convertView.
Hope this helps someone out there!