Don Del Grande
Don Del Grande

Reputation: 429

Eclipse won't recognize PNG in any drawable folder

I have an android app in Eclipse Kepler that has a background image called TheBackground.png.

I added TheBackground.png to res/drawable-mdpi, and my activity_main.xml starts with:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@drawable/TheBackground.png"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

but Eclipse throws this error at the android:background line:

No resource found that matches the given name (at 'background' with value '@drawable/TheBackground.png')

I have tried adding TheBackground.png to all of the res/drawable-*dpi folders, and creating a res/drawable folder and adding it there, but it returns the same error.

Note that the filename does point to a valid PNG image.

Am I missing something?

Upvotes: 1

Views: 2996

Answers (5)

MSA
MSA

Reputation: 2482

Rename your png image file, all chars must be lowercase.

 android:background="@drawable/the_background.png"

The resource compiler converts directory names to lower case before processing to avoid problems on case-insensitive file systems. Any capitalization in the names is only to benefit readability.

Upvotes: 4

Don Del Grande
Don Del Grande

Reputation: 429

Making it lowercase was half of the solution; apparently, it didn't like the ".png" added to it. When I changed it to "@drawable/the_background", it compiles successfully.

Upvotes: 0

Jazib
Jazib

Reputation: 1230

Rename your .png file to lower case.

Refresh your eclipse project by right clicking on project then Refresh, or by pressing F5 after clicking on project.

Clean it from Project->Clean and then u should be good to go!

Upvotes: 0

pavelkorolevxyz
pavelkorolevxyz

Reputation: 1500

You just don't need ".png" when set drawable. And use lower-case.

android:background="@drawable/the_background"

Upvotes: 2

M-sAnNan
M-sAnNan

Reputation: 804

change the name of png file to lower case

Upvotes: 1

Related Questions