Android error Duplicate Resources-ThrowExceptions

Exception or error:

I am very new to android development and am developing my first app when I got this error

Error:Error: Duplicate resources: E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png:drawable-hdpi-v4/login_bg, E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.9.png:drawable-hdpi-v4/login_bg
Error:Execution failed for task ':app:mergeDebugResources'.
> E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png: Error: Duplicate resources: E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png:drawable-hdpi-v4/login_bg, E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.9.png:drawable-hdpi-v4/login_bg

I am not able to properly understand the error. What file is duplicate here? What am I supposed to do to rectify it?

P.S. The UI was developed by my frnd who is an UI developer and then he mailed me the project on which I am now supposed to add code and functionality so it becomes hard for me to try and figure out what might be the possible error.

How to solve:

That’s because Android considers the following to be the same when you referenced the images in your layouts:


login_bg.9.png image tells Android that this image is a 9-patch image. Whereas, the other image, login_bg.png, is a normal image. But in terms of referencing the images, they are declared the same, as in the following examples.

Normal image:


Nine-patch image:


Note: There is no difference in terms of referencing the images from your /res/drawables directory of your Android project.

See here for more info about nine-patch image, or the correct term for it is nine-patch drawable. For reference, nine-patch drawables must be declared as <name>.9.png, as in login_bg.9.png.


basically it will occur whenever the xml detects multiple files with same name, regardless of their extension type.
e.g :
mypicture.jpg can not be in same directory folder with mypicture.png

so does with your case, login_bg.9.png and login.png in the same directory folder is not allowed.

hopefully this may be useful. have a good day


Solved this by going to :

Build ➞ Clean Project

Good luck!!


Delete the image from drawable directory because you are using same name director within one folder which is not allowed.


I solved this issue by renaming both files with different names.


Using Ant instead of Gradle seemed to fix the issue for me. Many of my files have the same filename to start with a different extension (indexed resource files of various types). Ancient project, and the ancient solution worked for me.


I find a same string name in my two diff .xml file,

<string name="dialog_subscribe">关注</string>
<string name="dialog_subscribe">subscribe</string>

then i solved it by rename one of then

Leave a Reply

Your email address will not be published. Required fields are marked *