22

I checked other posts that were similar and they recommended to clean the build path, but that did not help at all.
I have started android app development and am having a frustrating problem with adding a menu to an activity.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@+id/save_tea" android:title="@string/save_tea_label" />
</menu>

This throws the "Bad XML block: header size 60 or total size 3932356 is larger than data size 0" in the Eclipse console. I have a menu for the main app activity and it works fine, but this one cannot be combined into the R generated file.

I rewrote a bunch of my pages and it seems to work now, so I either missed something originally or eclipse decided to reevaluate the file.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Weston Boone
  • 345
  • 2
  • 3
  • 12
  • I have just copied ur code and tested. it works fine with out any error. – Seshu Vinay Jan 03 '12 at 05:34
  • Thanks I will concentrate on Eclipse as the problem then. I think that I am going to do a fresh install of it since it refuses to update through help->check for updates – Weston Boone Jan 03 '12 at 07:21
  • Did the accepted answer solve your problem? If it didn't we'd rather you didn't mark as accepted. – Kev Oct 31 '12 at 00:04
  • @Kev Yes and no if I remember correctly... It was awhile ago, but if memory serves I made a subtle typo in an XML file which was the cause of my error. After I fixed it I did have to do a Project->Clean so at the time I selected that answer. I suppose I should pick the more suitable answer now though. – Weston Boone Nov 01 '12 at 01:55
  • This error message appears whenever you have an error in your XML resources which you did not notice. For certain errors, it happens that Android Lint does not "see them" so that the resources are not marked as invalid and Eclipse does not prevent you from running the project. – caw Aug 16 '13 at 02:49

4 Answers4

16

I just ran into the same error message. In my case, the XML was referencing a missing icon file in the drawables folder.

Is it possible you did not have string/save_tea_label at the time of the error?

jfritz42
  • 5,913
  • 5
  • 50
  • 66
3

A Project->Clean should take care of this.

Edit: If a clean build didn't help, can you try replacing the XML file in question with the following contents (create a new file):

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
  <item
      android:id="@+id/save_tea"
      android:title="@string/save_tea_label" />
</menu>

The only thing I can think of is that a weird character got in there somehow (copy/paste?).

Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54
  • Yeah I tried that a couple of times, but to no avail... any other ideas? – Weston Boone Jan 03 '12 at 00:50
  • Nope no luck. I even copied over my other menu file and that did not help. Thanks for the attempt though any other suggestions? i am at a loss. I do not know if it is relevant but eclipse shows a different symbol by the file tab. The working one has an "X" for an icon and the one problem one has a backwards "D". – Weston Boone Jan 03 '12 at 01:20
  • @WestonBoone Can you have a look through this question: http://stackoverflow.com/questions/5588086/eclipse-hangs-when-trying-to-add-menu-xml – Marvin Pinto Jan 03 '12 at 01:24
  • @WestonBoone This seems like an obvious Eclipse issue - can you give the workaround (answer) a try? I'm not sure how much sense that makes because I don't use Eclipse myself. What Eclipse version are you using? – Marvin Pinto Jan 03 '12 at 01:25
  • I have the indigo release of eclipse and tried using the wizard and doing it manually with no results. I am updating Eclipse to the most current release and will try to add the file again. I just started using eclipse myself so this is all a learning experience – Weston Boone Jan 03 '12 at 01:39
1

Make sure you are not using any APIs not available for the API level you are developing for. See this post for details; Error in the sample code “bluetooth chat”

Community
  • 1
  • 1
Mudassir
  • 13,031
  • 8
  • 59
  • 87
  • I will go through my code to make sure, but the I should be okay. I am working through a android tutorial that I found. http://coding.smashingmagazine.com/2011/03/28/get-started-developing-for-android-with-eclipse-reloaded/ The app is pretty trivial and I have the minsdk version set at three and am running it on a android 2.2 emulator – Weston Boone Jan 03 '12 at 05:11
  • Remove the `minSdkVersion` attribute then test it. – Mudassir Jan 03 '12 at 05:56
  • No change... I am pretty sure that it is purely an eclipse problem, but I cant get it to do a successful build with the error so I can't test it on my phone – Weston Boone Jan 03 '12 at 06:49
  • What is the value of `save_tea_label`..? – Mudassir Jan 03 '12 at 07:35
  • I just rewrote my strings.xml page and both my menus from scratch and it builds fine now so I might have had a typo in there that I overlooked again and again. Sorry for wasting everyone's time if that oversight was the problem – Weston Boone Jan 03 '12 at 07:41
0

For me, I tried to add a @drawable/add.png to a menu item's icon attribute before realising that it's a declarative literal and not a bloody path.

Simply removing the .png and my problem was solved q:)

Encoder
  • 525
  • 1
  • 4
  • 15