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

Help! My Android app isn't working!

Hi. When I try to run my app, my picture doesn't show. And, when I press "Enlighten Me!" It doesn't do anything. I don't understand what I did wrong. Please help!

8 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Hi Pootis,

You might want to post some code or zip up your project and send it to help@teamtreehouse.com so that Ben our Android teacher can look at it.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Yes, please zip it up and send it along! Perhaps the image file is in the wrong place, and maybe there is a typo or something in the OnClickListener for the button. If you send your code I can hopefully find the problem quickly. Or even post some code in here and see if the members can help. :-)

Ok , Thanks :)

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Got your code and I'm replying here in case anyone else runs into these same problems. :)

First, the button isn't doing anything because an important line is missing. Maybe it was deleted during the Simple Refactoring video? Check out how the code looks around the 10 minute mark and you should see what's missing from the onClick() method.

The Crystal Ball image is missing because file names in the "res" directory of Android projects can only have letters, numbers, or underscores. All the letters must be lowercase, too. White space and capital letters are not allowed. It looks like you renamed "crystal_ball.png" to "Crystal Ball Layout.png". Try renaming it (and updating the name in activity_main.xml) and the image should show up for you.

Hope this helps! Reply back if you need any further details.

Thanks!

EDIT: I did what you said, but still nothing happened. I'll send it again.

Is it possible that the problem has something to do with the emulator rather than the code?

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

There were two definite problems with the code. If those are fixed then it could possibly be a problem with the emulator, but I doubt it if the emulator works otherwise.

Problem 1: setText() missing

In your onClick() method, the line answerLabel.setText(answer) was missing after answer is set.

Problem 2: Crystal Ball Layout.png is an invalid name

You need to rename that file to crystal ball.png (no caps or whitespace) and then also change the reference to the filename in the Image View background attribute. It should be "@drawable/crystal_ball"

Verify that these are fixed correctly, and if you are still having problems, send your code again or paste it in here.

Good luck!

:D It worked! Thank you :)