14

I have a build fail due to the following error

[aapt] res/drawable-xhdpi/splash.png:0: error: Resource entry splash is already defined.

[aapt] res/drawable-xhdpi/splash.9.png:0: Originally defined here.

Any ideas? Thanks!

sbs
  • 4,102
  • 5
  • 40
  • 54

8 Answers8

25

This error could also happen, if you use cordova and renamed an existing image (in my case there was only splash.9.png present, but the same error occurred.

In this case you need to clean the project, using

./platforms/android/cordova/clean
VMAtm
  • 27,943
  • 17
  • 79
  • 125
Harald
  • 614
  • 1
  • 6
  • 6
11

You cannot include something.png and something.9.png at the same time. Delete or rename one of them.

Yuichi Araki
  • 3,438
  • 1
  • 19
  • 24
5

All of the above answers where wrong for me :D The problem was, that ive had already compiled once with files named splash.png (actually: screen.png in my case).

After draw9patching and renaming them to .9.png (which you have to in order to make them work) I had to remove all files in ant-build to get rid of the error: the compiler seems to sort of correctly fail because he gets two different files with the same name by ignoring the different extension.

user3895700
  • 51
  • 1
  • 1
  • The above answer from "Harald" does this in a more controlled manner :) – Moulde Apr 01 '15 at 07:29
  • @Moulde A clean will also fail due to the error. This is the correct answer if you have already built the project and then renamed the resource. – MatthiasFranz Apr 23 '15 at 17:20
2

You have two files in resources splash.png and splash.9.png.You cannot include splash.png and splash.9.png at the same time.

Delete the file not being used and the compile you will be able to build successfully.

Shruti
  • 1
  • 13
  • 55
  • 95
2

As you are using two image with same name, one is simple one and another is nine patch which cause error, delete one of which you are not using or you don't wanna use.

which is not in use then delete splash.png or /splash.9.png

RobinHood
  • 10,897
  • 4
  • 48
  • 97
2

rename the splash.png to something else. splash.9.png is valid if it is 9-patched. But you cannot keep both splash.png and splash.9.png.

Prachi
  • 3,584
  • 2
  • 24
  • 39
2

Rename splash.9.png to splashnew.png .

Never use "." "_" etc other special characters for your resource images and files!

You can remove the dots and name it splash9.png

Ref:http://developer.android.com/tools/help/draw9patch.html

Note: A normal PNG file (.png) will be loaded with an empty one-pixel border added around the image, in which you can draw the stretchable patches and content area. A previously saved 9-patch file (.9.png) will be loaded as-is, with no drawing area added, because it already exists.

Metalhead1247
  • 1,978
  • 1
  • 17
  • 28
  • 1
    but it seem OP used nine patch image which having an extension `name.9.png` , correct me If I'm wrong? – RobinHood Sep 12 '13 at 06:12
  • 1
    @RobinHood you cannot use names such as name dot any thing becoz .9 becomes an extension that's why an error is thrown. you can use 9 patch images ,you just have to rename it if there is any.9.png and change it to .png – Metalhead1247 Sep 12 '13 at 06:45
  • but nine patch by default providing name with `.9` extenstion, example: `image.9.png`and android support extension nicely! – RobinHood Sep 12 '13 at 06:53
  • @RobinHood Note: A normal PNG file (*.png) will be loaded with an empty one-pixel border added around the image, in which you can draw the stretchable patches and content area. A previously saved 9-patch file (*.9.png) will be loaded as-is, with no drawing area added, because it already exists. – Metalhead1247 Sep 12 '13 at 07:01
0

To me this was my solution First perform this action

cordova clean

And you can now do this

cordova build android
Blaze
  • 2,269
  • 11
  • 40
  • 82