Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Retrieving and Viewing Messages Creating a Custom List Adapter for Messages

Sousheel Vunnam
Sousheel Vunnam
3,366 Points

App crashing after a second - Probably Custom List adapter

Whenever I start Ribbit, it crashes after starting up. I am able to see the home screen for a little. This is probably attributed to the custom list adapter because before it was working fine. I tried debugging it and found the same result that it was crashing after the list adapter. The logcat says there is a fatal exception in MAIN and gives a bunch of NULLPOINTEREXCEPTIONs.

Here is the fatal exception: https://gist.github.com/soush915/1564e48a5e60398c8846

1 Answer

Doug Ray
Doug Ray
7,493 Points

Hey Sousheel !

So whenever you get a null pointer exception it basically means that the system was expecting a value for something it was pointing to and what it was given was null or empty. In your case the culprit is at

android.widget.AbsListView.obtainView(AbsListView.java:2161).

Most of the time this is because you forgot to initialize the view with the findViewById(R.id.AbsListView) call and only initialized it like this ListView AbsListView;

If this is not it than the next thing to check is the data that you are passing into the adapter trying to give a null value to your adapter could cause this as well !

Hope this helps

Doug4less =D

Sousheel Vunnam
Sousheel Vunnam
3,366 Points

I was actually returning null rather than convertView in the getView method. Thank you for the help!