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 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!