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

I cant add image to the res. it gives me an error

I am following CrsytalBall but I am not able to add image. I downloaded the image and added it to res directory under drawable_mdpi. Then when I try to add the image on the view using imageView, it gives me this error

Couldn't resolve resource @drawable/ball01 Failed to convert @drawable/ball01 into a drawable

Here is my xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" tools:ignore="MergeRootFrame" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView"
    android:layout_gravity="center"
    android:textSize="32sp"
    android:layout_above="@+id/button"
    android:layout_centerHorizontal="true" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Enlighten Me"
    android:id="@+id/button"

    android:layout_centerVertical="true"
    android:layout_alignParentRight="true" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:layout_above="@+id/textView"
    android:layout_centerHorizontal="true"
    android:src="@drawable/ball01" />

</RelativeLayout>

What am I doing wrong here.

ok it is so dumb. I had to close IDE and then reopen it and it found the image fine then. There has to be a better way than that! Anywho..everything under control now

3 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Eclipse can be a little weird sometimes. :) I can't say why that would have happened or why restarting it worked, but I'm glad you got past it!

Thank you for your answer. Quick question, I am interested in a sample application that uses restful apis to grab data. I thought this course would teach it but it doesnt look like it anymore. Am I missing something. Thanks

Ah I think its this "Build a Blog Reader Android App"...cool