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

Beginners Android App HELP!

I'm trying to build the beginners android app but i am stuck at "Pretty Little Things > Adding an Image". In the android manifest I have an error at "<Activity" (line 14) that says "com.example.crystalball.MainActivity, was not found in the project or the libraries"...

I have looked it over many times and can't seem to find my mistake. Any help would be greatly appreciated, Thank You.

4 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

A few things to try:

  • If you are following along exactly with the videos then you might need a period between "crystal" and "ball" in the package name.
  • Can you paste in all your XML from the manifest file in here? You can edit your original comment and paste it below. You can make it look like code by adding three backticks and "xml" on the line above it and then three backticks below it, like this:

```xml <Test/>

```

<Test/>
  • Also, if you want, you can zip up your project and email help@teamtreehouse.com and I can take a look to see where the problem might be.

I think it might be easier to email a zip file to you because the problem might be a bit bigger. Thank you for your time, I'm really excited to take on the challenges Treehouse has to offer me.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Got your code but I'm replying in here to help anyone else who stumbles onto this problem.

You found an annoying "feature" of Android projects. When I opened your app in Eclipse, I saw in the Problems tab at the bottom the error "Unparsed aapt error(s)! Check the console for output." That doesn't help us at all except to tell us where to look next. Clicking over the to Console tab, we see the error "res/drawable-mdpi/CrystalBallLogo.jpg: Invalid file name: must contain only [a-z0-9_.]"

So filenames anywhere in "res" must only contain lowercase letters, numbers, or underscores. The uppercase letters in "CrystalBallLogo" were causing this error. If you change the filename to all lowercase that should fix your problem. And don't forget to change the name in your layout file.

You may need to clean your project when you're done (Project > Clean...). I ran into a strange error with the layout file, but it may have been because I had another Crystal Ball project open. I had to overwrite the existing layout file.

I am experiencing a similar error, I changed the file name to lowercase and still have errors.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Gregg, can you post your exact error in here? Or as Brandon did, zip up your project and send it to help@teamtreehouse.com and I can take a look.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Got your code! When I opened it up, I saw the errors in MainActivity as well as in activity_main.xml within your res/layout directory. I opened up the layout and switched to the XML view. The error in the XML file is regarding the file "quotes01". I'm assuming this is the file whose name you changed, but that file is not included in the project directory.

Likewise, you have a 2nd ImageView that refers to "Quotes01", which you'll need to delete (or change).

So check your image file and make sure you put it in one of the drawable directories within the res directory. If you get the appropriately named file in the right place, then your errors for it should go away. Let us know if you get it working!

Thanks...just inserted the file into the drawable-mdpi file under the res. However, I still get an error.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Got it working with a few tweaks...I should have done this earlier for a better write-up! Give the following a shot:

  1. Add quotes01.png to your drawable directory (as you've already done).
  2. Delete the 2nd ImageView from the XML view of activity_main.xml (the one that refers to "Quotes01").
  3. Update AndroidManifest.xml. It references a String resource that doesn't exist in your project: @string/title_activity_main. You can either change this in the XML view of the manifest to some hard-coded string, or add a new String resource in strings.xml named title_activity_main.
  4. Clean and rebuild! You may need to organize your imports in MainActivity.java. It should be okay, but if it shows any errors at this point you may need to delete the line that says import android.R;

Hope this helps!

It worked great! Thanks Ben.