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 Simple Android App with Java Basic Android Programming Generating a Random Number

App crashes now

I'm moving along in this course (without any help from the community nor the teachers) but it's going slow since there are discrepancies between the video instructions and what I am myself trying to do.

Can't anybody help me? I'm paying for these classes and right now it feels pretty wasted. I cannot develop my knowledge regarding the topic at any speed at all.

I'm stuck when I try to 'Run' the app again. The message in the emulator says "Fun Facts has stopped" which I guess is a crash, but I cannot find any way to solve it.

There must be somebody in this community that can provide me some help, especially the teacher, right? I'm getting tired of all my own work arounds...

Grateful for ay assistance!

Hey, so I recently (last week) completed the Fun Facts course as well, but didn't have any problems. You mention that there are discrepancies between the video instructions and what you are trying to do. Maybe you are doing something wrong? Try following the video more closely.

Also, somewhere in the beginner track it provides a number of tips on how to debug your application. I thought it was in the Fun Facts tutorial, but just in case you haven't gotten there yet. Here are some things to try:

  • Look at the bottom of the editor for the "Logcat" and "Messages" tab. Error messages should appear there. If these messages don't narrow it down enough and you still need help. Post those messages in your post so those reading it can have a better idea of what you are doing wrong.
  • Try removing code you have added back to the point where it compiles again. Once it compiles add pieces back until it breaks and then you should know what line is causing it.

There were some other really good tips for debugging in the videos.

Good Luck!

Thank you so much, the both of you!

Especially you, Christoffer. I actually have started over in the class one time already, but it didn't improve my situation so much.

I'm gonna start all over again on Monday and I'll let you know how it goes. I've already looked into logcat a little bit, also thanks to stackoverflow.com, but it's pretty hard to make anything out.

(Here is my red text in logcat:

12-08 16:01:11.209 5546-5546/se.inresonance.funfacts E/AndroidRuntime: FATAL EXCEPTION: main Process: se.inresonance.funfacts, PID: 5546 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at se.inresonance.funfacts.FunFactsActivity$1.onClick(FunFactsActivity.java:36) at android.view.View.performClick(View.java:6294) at android.view.View$PerformClick.run(View.java:24770) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

End of logcat.)

Can you make anything out of this? Or anyone else?

2 Answers

I'm sorry. I cannot help you. However, I have asked a variety of other students.

Take a close look at FunFactsActivity.java line 36 It looks like you are calling setText on a null TextView there.

It's a great example! The video clearly say I should write setText(fact), but in the video it's written on line 28, instead of line 36.

One of the discrepancies that I was mentioning before. I'll start the course over today.

Thank you so much anyways!