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

Jeff Burn
839 PointsNull Pointer Exception - Blog Reader/Finishing our Async Task
I am receiving a null pointer exception. What is the best way to troubleshoot this error message? Thanks
9-18 23:01:59.183 1237-1237/com.example.jbunn.blogreader E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.jbunn.blogreader, PID: 1237 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jbunn.blogreader/com.example.jbunn.blogreader.MyListActivity}: java.lang.NullPointerException: storage == null at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException: storage == null at java.util.Arrays$ArrayList.<init>(Arrays.java:38) at java.util.Arrays.asList(Arrays.java:155) at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:128) at com.example.jbunn.blogreader.MyListActivity.onCreate(MyListActivity.java:52) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) 09-18 23:02:04.623 1237-1250/com.example.jbunn.blogreader I/MyListActivity﹕ Code: 200 09-18 23:06:59.603 1237-1237/com.example.jbunn.blogreader I/Process﹕ Sending signal. PID: 1237 SIG: 9

Harry James
14,780 PointsHello Thang! Could you please open up a new forum post with the full LogCat of your error?
Then, go ahead and tag me in your post by typing @Harry James
and I will make sure to take a look for you! :)

Thang Pham Quoc
73 PointsHarry James It's weird that it's gone after I closed and reopened the Android Studio. It was there even if I tried to rebuild the project

Harry James
14,780 PointsThat does happen from time to time - usually it's actually your emulator that causes it and closing and re-opening or creating a new emulator tends to fix the problem. I get them myself if I try to do things too quick as well.
Glad to hear that the problem is sorted now though! :)
2 Answers

Harry James
14,780 PointsA null pointer exception basically means that you're trying to do something to null. For example:
example = null;
example.doThisMethod();
// You will get a null pointer exception here as, you're doing null.doThisMethod() technically.
I'm not sure exactly where the problem lies in your project but I'd give MyListActivity.java line 52 a try. If not, continue looking around and try Debug mode to see where it is that the app actually crashes.
If you are really stuck, feel free to post your Project Files on here (By exporting the project and saving it onto a Cloud Storage service) and I'll see if I can track down the problem.

Boris Vukobrat
4,248 PointsIn your file Arrays.java at line 38 you have a null where it shouldn't be : ) Look in error log for "caused by"
Thang Pham Quoc
73 PointsThang Pham Quoc
73 PointsI'm having the same problem as yours. Have you figured out a solution for this ?