I paste image inside the drawable folder in android studio 4.1 , it shows red lines (error line) in image name

Viewed 7671

This is my project folder, when i adding first image then it not show any error but after adding the 2nd and 3rd image it show the red lines. I don't know where i do mistake, if anyone knows then please help me.

enter image description here

7 Answers

In Android Studio, click on View > Tool Windows > Resource Manager in the menus or click on the Resource Manager tab to the left of the Project window. Click the + below Resource Manager, and select Import Drawables. This opens a file browser.

Make sure the name of the image you are trying to add does not resemble some keyword. I was trying to add an image in drawable with name "try". When i made it "tried" error went away. So, name your image != any keyword.

FOR YOUR CASE IN PARTICULAR:

Try invalidating cache and restarting it. Moreover, also check if the problem persists only with these two images or others too.

Names should be in lowercase. Therefore never use names with uppercase letters in it

try removing numerals and keep a meaningful name. Also ensure that the names are in lower case

drawable folder is wrong place for png files. In drawable are stored xml files

All png files should be stored in mipmap folders

If you want have only one png for all resolutions, store it in mipmap-anydpi

I found the problem. Add the same image to the default drawable folder. Android Studio automatically doesn't add it to the default drawable folder.

It usually happen because of the name assigned to image file. try to put the name of file in snake_case.[error][solution]

solutionC.pngerror

Related