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 Using Picasso to View Images from the Web

Ilya Liverts
Ilya Liverts
9,677 Points

Null Pointer Exception in onListItemClick()

When I try to click on item ,Ribbit crashes with runtime exception:

04-17 10:53:31.691 1261-1261/com.teamtreehouse.ribbit E/AndroidRuntime? FATAL EXCEPTION: main java.lang.NullPointerException at com.teamtreehouse.ribbit.InboxFragment.onListItemClick(InboxFragment.java:70) at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58) at android.widget.AdapterView.performItemClick(AdapterView.java:298) at android.widget.AbsListView.performItemClick(AbsListView.java:1100) at android.widget.AbsListView$PerformClick.run(AbsListView.java:2788) at android.widget.AbsListView$1.run(AbsListView.java:3463) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method)

1 Answer

william parrish
william parrish
13,774 Points

Well, the error is giving you this information : NullPointerException at com.teamtreehouse.ribbit.InboxFragment.onListItemClick(InboxFragment.java:70) at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)

That means on line 70 of your InboxFragment, and Line 58 of your ListFragment, you are referencing something that doesnt exist or cannot be found. Start at those lines, and make sure your variables are correct. If that doesnt work, post your code from those two Fragments so we can compare them.