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, 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( at android.view.View.performClick( at android.view.View$ at android.os.Handler.handleCallback( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at at java.lang.reflect.Method.invoke(Native Method) at$ at

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