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 Simple Android App (2014) Improving Our Code Adding an App Icon

Steve Kinsey
Steve Kinsey
4,463 Points

Fun Facts has stopped

I'm up as far as debugging section but when I run my app and click on the button the app stops working in the emulator and I get 'Fun Facts has stopped' :-(

Tried it in a couple of different emulators I created and also using a Genymotion emulator but still getting the same message.

Bit annoying after all that work...anyone got any ideas or come across something similar?

Thanks Treehousers :-)

Steve K

What error message are you getting in logcat?

Harry James
Harry James
14,780 Points

Hey Steve!

Not to worry! We can get this fixed in little to no time!

Open the logcat view by clicking on the Android tab at the bottom of Android Studio. If you can't see this tab, you can access it by moving your mouse to the bottom left hand corner of Android Studio. Then, set the Log level to Error and paste the contents of the logcat window onto this forum so that we can take a look! This diagram below shows how to do this:

High res for small screens

4 Answers

Harry James
Harry James
14,780 Points

Woohoo!

Glad you got it fixed Steve!

Also, for future reference, you don't have to go through all of the code. From the line ColorWheel.java:38, we can see that there's a problem in ColorWheel.java on line 38! It's not magic, it's just it's not obvious when you first look there!

Sometimes the logcat will tell you there's an error on a line that doesn't have an error but, usually the problem lies around that line (It's usually exactly on the line but, it depends on the code you are writing). Also, the problem might be elsewhere like Color.java:225 (In this case, it wasn't) so, it's worth trying a few of the classes it talks about if you get a problem like this (But don't check the Android classes like View.java or Color.java - it won't be in there!)

Oh and, Genymotion is the way to go! I made sure that was the first thing I installed after Android Studio xD

Hope it helps! :)

Steve Kinsey
Steve Kinsey
4,463 Points

That's really helpful Harry, thanks for taking the time man I appreciate it.

Oh, how would I find line 225? I mean, I have line numbers turned on, but any code I entered and/or screwed around with (or screwed up, ha ha) is nowhere near 225 lines long. I'm assuming it's possibly line 225 of the full run or something like that, but obviously being able to pinpoint line 225 is key to fixing a problem there.

Sorry man, full of questions about this software...although I am quite enjoying it :-)

Cheers Steve

PS A-ha, you just click in logcat and it takes you there...that's kinda cool!!!

Harry James
Harry James
14,780 Points

Woops! Sorry, I linked the wrong line! Proves my point that it's not always the first one! Color.java is in fact an Android class and it's the 2nd line:

 at com.example.home.funfacts.ColorWheel.getColor(ColorWheel.java:38)

Where the error occurs! (In the ColorWheel class at line 38).

I'll update that in my answer above as well before anyone else notices :o

And, ask away! I learn best by answering questions and asking them so that's why I love doing this :)

Steve Kinsey
Steve Kinsey
4,463 Points

Cheers guys...am trying to run it again but can't get an emulator going...having a 'mare ;-)

Steve Kinsey
Steve Kinsey
4,463 Points

OK...

02-17 21:49:59.369    1434-1434/com.example.home.funfacts E/OpenGLRenderer Getting MAX_TEXTURE_SIZE from GradienCache

02-17 21:49:59.397    1434-1434/com.example.home.funfacts E/OpenGLRenderer MAX_TEXTURE_SIZE: 8192

02-17 21:49:59.461    1434-1434/com.example.home.funfacts E/OpenGLRenderer Getting MAX_TEXTURE_SIZE from Caches::initConstraints()

02-17 21:49:59.465    1434-1434/com.example.home.funfacts E/OpenGLRenderer MAX_TEXTURE_SIZE: 8192

02-17 21:50:23.280    1434-1434/com.example.home.funfacts E/AndroidRuntime FATAL EXCEPTION: main

    Process: com.example.home.funfacts, PID: 1434
    java.lang.IllegalArgumentException: Unknown color
            at android.graphics.Color.parseColor(Color.java:225)
            at com.example.home.funfacts.ColorWheel.getColor(ColorWheel.java:38)
            at com.example.home.funfacts.FunFactsActivity$1.onClick(FunFactsActivity.java:40)
            at android.view.View.performClick(View.java:4438)
            at android.view.View$PerformClick.run(View.java:18422)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            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:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

'Unknown colour'??? Maybe I go back check my colour codes on the colour wheel...

Steve Kinsey
Steve Kinsey
4,463 Points

Went back and copied all the color codes in again and seems to be working ok now, finally (I also used a new Genymotion emulator I'd made to be almost the same as the Nexus 5 set-up in the tutorials...jeez these emulators are soooooooo sloooooooooowwwwwwww)

Thanks for the tip about changing the log level to setting to error...I think that's gonna come in VERY handy :-)

Peace Steve K