6

I created a new project in Android Lollipop (API 21) using Studio(64) and Java 7. When I try to add a background on main layout (relative layout) I am getting error

enter image description here

My res folder structure is

enter image description here

NOTE: I have placed 720x1280 img in all drawable* folders.

My XML is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:padding="0dp"
    android:background="@drawable/homebackground">

</RelativeLayout>

I tried using PNG / JPG.. but still I am getting same error. Can someone tell where am I going wrong ?


I referred these, but they are not related to my problem or don't solve my problem

Couldn't resolve resource @drawable/backround.png

RelativeLayout "Couldn't resolve resource..." Android

Android image can't convert to drawable

Community
  • 1
  • 1
SimpleGuy
  • 2,764
  • 5
  • 28
  • 45

3 Answers3

9

If you are using Android Studio, clicking on File > Invalidate caches/restart should solve the problem.

GunnerFan
  • 3,576
  • 3
  • 25
  • 38
0

Inside the Manifest file .....in the field where there is @drawable/homeground replace that with @android:drawable/homeground

Eco4ndly
  • 515
  • 1
  • 5
  • 22
0

I tried "invalidate caches/restart" but it didn't work for me. So to solve this I moved my image(night_sky.jpg) from drawable to mipmap folder and the error was gone. It worked for me hope it will work for you also

Image for reference:

image for reference

m4n0
  • 29,823
  • 27
  • 76
  • 89
Anant Bharti
  • 51
  • 1
  • 4