Android错误重复资源 [英] Android error Duplicate Resources
问题描述
我对android开发非常陌生,并且在遇到此错误时正在开发我的第一个应用程序
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.该UI由我的UI开发人员frnd开发,然后他邮寄给我一个我现在应该在上面添加代码和功能的项目,因此我很难尝试找出可能的错误.>
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.
推荐答案
这是因为当您在布局中引用图像时,Android认为以下内容是相同的:
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
图像告诉Android该图像是一个9补丁图像.而另一个图像login_bg.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.
正常图像:
<ImageView
android:id="@+id/normalImage"
android:background="@drawable/login_bg"/>
九幅图像:
<ImageView
android:id="@+id/ninePatchImage"
android:background="@drawable/login_bg"/>
注意:从Android项目的/res/drawables
目录中引用图像没有区别.
Note: There is no difference in terms of referencing the images from your /res/drawables
directory of your Android project.
请参阅此处,以获取有关九补丁图像或其正确术语的更多信息.可绘制九个补丁.作为参考,与login_bg.9.png
中一样,必须将九个修补程序 声明为<name>.9.png
.
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
.
这篇关于Android错误重复资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!