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.
That's because Android considers the following to be the same when you referenced the images in your layouts:
E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.9.png
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:
<ImageView android:id="@+id/normalImage" android:background="@drawable/login_bg"/>
Nine-patch image:
<ImageView android:id="@+id/ninePatchImage" android:background="@drawable/login_bg"/>
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_bg.png
in the same directory folder is not allowed.
hopefully this may be useful. have a good day
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With