Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid style Resources compile (aapt) failing : Bad resource table: header size 0xc
    primarykey
    data
    text
    <p>I just spent a few hours with a horrible Android Resource pre compile problem to do with styles and was wondering could anyone explain what caused it. I fixed it but dont know whats the problem. Not helped by Android saying the error was in colors.xml and not in another xml.</p> <p>Step 1 - to recreate error</p> <pre><code>Given a style &lt;style name="ActionBarTitleContainer"&gt; &lt;item name="android:id"&gt;@id/title_container&lt;/item&gt; &lt;item name="android:layout_width"&gt;fill_parent&lt;/item&gt; &lt;item name="android:layout_height"&gt;@dimen/title_height&lt;/item&gt; &lt;item name="android:orientation"&gt;horizontal&lt;/item&gt; &lt;item name="android:background"&gt;@color/title_color_light&lt;/item&gt; &lt;/style&gt; </code></pre> <p>I copied it, gave it new, android:id</p> <pre><code> &lt;item name="android:id"&gt;@id/info_container&lt;/item&gt; &lt;style name="ActionBarTitleContainer"&gt; &lt;item name="android:id"&gt;@id/title_container&lt;/item&gt; &lt;item name="android:layout_width"&gt;fill_parent&lt;/item&gt; &lt;item name="android:layout_height"&gt;@dimen/title_height&lt;/item&gt; &lt;item name="android:orientation"&gt;horizontal&lt;/item&gt; &lt;item name="android:background"&gt;@color/title_color_light&lt;/item&gt; &lt;/style&gt; &lt;style name="ActionBarInfoContainer"&gt; &lt;item name="android:id"&gt;@id/info_container&lt;/item&gt; &lt;item name="android:layout_width"&gt;fill_parent&lt;/item&gt; &lt;item name="android:layout_height"&gt;@dimen/info_height1&lt;/item&gt; &lt;item name="android:orientation"&gt;horizontal&lt;/item&gt; &lt;item name="android:background"&gt;@color/title_color_light&lt;/item&gt; &lt;/style&gt; </code></pre> <p>Saved and Compile said error in id</p> <pre><code>&lt;style name="ActionBarInfoContainer"&gt; &lt;item name="android:id"&gt;@id/info_container&lt;/item&gt; Description Resource Path Location Type error: Error: No resource found that matches the given name (at 'android:id' with value '@id/info_container'). styles.xml /MyApp/res/values line 68 Android AAPT Problem </code></pre> <p>So mistakenly I added a + before the id</p> <pre><code>&lt;style name="ActionBarInfoContainer"&gt; &lt;item name="android:id"&gt;@+id/info_container&lt;/item&gt; </code></pre> <p>Then got error</p> <pre><code>W/ResourceType( 2202): Bad resource table: header size 0xc or total size 0x4aba is not on an integer boundary W/ResourceType( 2202): Bad resource table: header size 0xc or total size 0x4aba is not on an integer boundary ERROR: Unable to parse generated resources, aborting. 'aapt' error. Pre Compiler Build aborted. </code></pre> <p>Sadly I had added a lot of style etc not just this one so spent ages back tracking to find the error. Not helped by Android saying error occuring in colors.xml when it wasnt.</p> <p>Fixed by</p> <p>removing the + from styles.xml</p> <p>placing new id in ids.xml</p> <pre><code> &lt;style name="ActionBarTitleContainer"&gt; &lt;item name="android:id"&gt;@id/title_container&lt;/item&gt; .... &lt;/style&gt; &lt;style name="ActionBarInfoContainer"&gt; &lt;item name="android:id"&gt;@id/info_container&lt;/item&gt; .... &lt;/style&gt; </code></pre> <p>Changed @+id/info_container to @id/info_container</p> <p>And adding id to ids.xml</p> <pre><code>&lt;resources&gt; &lt;item type="id" name="title_container" /&gt; &lt;item type="id" name="info_container" /&gt; </code></pre> <p>Any idea what the error means because it took me a few hours of pain to track it down. </p> <p>Not helped by Android aapt compiler saying the error was caused around colors.xml.</p> <p>Is this error caused by me compiling against 2.1U1?</p> <p>I have the latest SDK but there is an aapt in each platform folder but date against it is APR 2011. </p> <p><HR /> And for future reference as I found very little info on aapt resource compiling. Heres some tips for people with Resource compilation errors, so you dont lose hours on bad google error reporting:</p> <p>TIP 1 - TURN ON VERBOSE ANDROID BUILD OUTPUT</p> <pre><code>Open Eclipse Preferences Open in the list on the left Android Build Set Build output to Verbose Hit OK Open Console View Window &gt; View &gt; Console Do clean build or type a space in and file and hit save if you dont want to do full build Resources compiler aapt will run first and throw error </code></pre> <p>Two issues</p> <p>Issue 1 - error in red may appear in output in confusing location</p> <p>probably caused by Exception being throw in a thread but other files still compile ok before build process fully stops.</p> <p>Notice here how the error seems to occur after nearest_bus_stops_layout.xml. </p> <pre><code>[2011-05-15 16:22:25 - MyApp] (new resource id filechooser_file_view from /Users/user1/Documents/workspace/MyApp/res/layout/filechooser_file_view.xml) [2011-05-15 16:22:25 - MyApp] (new resource id listbusmapsactivity_layout from /Users/user1/Documents/workspace/MyApp/res/layout/listbusmapsactivity_layout.xml) [2011-05-15 16:22:25 - MyApp] (new resource id nearest_bus_maps_layout from /Users/user1/Documents/workspace/MyApp/res/layout/nearest_bus_maps_layout.xml) [2011-05-15 16:22:25 - MyApp] (new resource id nearest_bus_stops_layout from /Users/user1/Documents/workspace/MyApp/res/layout/nearest_bus_stops_layout.xml) [2011-05-15 16:22:25 - MyApp] W/ResourceType( 2247): Bad resource table: header size 0xc or total size 0x4aba is not on an integer boundary [2011-05-15 16:22:25 - MyApp] W/ResourceType( 2247): Bad resource table: header size 0xc or total size 0x4aba is not on an integer boundary [2011-05-15 16:22:25 - MyApp] ERROR: Unable to parse generated resources, aborting. [2011-05-15 16:22:25 - MyApp] (new resource id open_web_page_activity from /Users/user1/Documents/workspace/MyApp/res/layout/open_web_page_activity.xml) [2011-05-15 16:22:25 - MyApp] (new resource id send_email_activity from /Users/user1/Documents/workspace/MyApp/res/layout/send_email_activity.xml) [2011-05-15 16:22:25 - MyApp] 'aapt' error. Pre Compiler Build aborted. </code></pre> <p>THIS IS NOT THE FILE WHERE THE ERROR IS.</p> <p>TIP: How to FIND WHICH FILE EXACTLY CAUSING THE PROBLEM</p> <p>Find the last file that's mentioned before the error message:</p> <pre><code>'aapt' error. Pre Compiler Build aborted. </code></pre> <p>This is</p> <pre><code>/send_email_activity.xml </code></pre> <p>PROBLEM: send_email_activity.xml isnt the file with the error.</p> <p>send_email_activity.xml compiled ok and was output.</p> <p>ITS THE ONE AFTER /send_email_activity.xml that we want</p> <p>Problem: filename that threw the error missing. </p> <p>How to Find the file AFTER /send_email_activity.xml that caused the error</p> <p>Scroll UP in console output to </p> <pre><code>Files: </code></pre> <p>The aapt compiler lists all files its found and is going to compile. </p> <p>Luckily the order in Files: is the same as when the error is thrown down below</p> <p>Look for the last file to compile (send_email_activity.xml) in the Files: section</p> <pre><code>TIP In the Console window find the last file that compiled ok before the error 'send_email_activity.xml' And do CTRL/CMD(Mac) + F for previous occurrences under the Files: section </code></pre> <p>We can see here that /send_email_activity.xml is followed by colors.xml</p> <pre><code>Files: drawable/alphabet_bar_bg.xml Src: /Users/clearbrian/Documents/workspace/LondonBusStopMaps/res/drawable/alphabet_bar_bg.xml drawable/alphabet_separator_bg.xml Src: /Users/clearbrian/Documents/workspace/LondonBusStopMaps/res/drawable/alphabet_separator_bg.xml ....... layout/send_email_activity.xml Src: /Users/clearbrian/Documents/workspace/LondonBusStopMaps/res/layout/send_email_activity.xml values/colors.xml Src: /Users/clearbrian/Documents/workspace/LondonBusStopMaps/res/values/colors.xml ....... values/themes.xml Src: /Users/clearbrian/Documents/workspace/LondonBusStopMaps/res/values/themes.xml AndroidManifest.xml Src: /Users/clearbrian/Documents/workspace/LondonBusStopMaps/AndroidManifest.xml </code></pre> <p>ANSWER: colors.xml IS THE FILE THAT CAUSED 'aapt' error. Pre Compiler Build aborted.</p> <p>And also the error:</p> <pre><code>[2011-05-15 16:22:25 - MyApp] W/ResourceType( 2247): Bad resource table: header size 0xc or total size 0x4aba is not on an integer boundary [2011-05-15 16:22:25 - MyApp] W/ResourceType( 2247): Bad resource table: header size 0xc or total size 0x4aba is not on an integer boundary [2011-05-15 16:22:25 - MyApp] ERROR: Unable to parse generated resources, aborting. </code></pre> <p>Problem 2: the error ISNT in colors.xml. </p> <p>I had changed a color value in colors.xml </p> <p>but it had been referenced in styles.xml</p> <p>styles.xml</p> <pre><code> &lt;style name="ActionBarInfoContainer"&gt; &lt;item name="android:id"&gt;@id/info_container&lt;/item&gt; ... &lt;item name="android:background"&gt;@color/title_color_light&lt;/item&gt; &lt;/style&gt; </code></pre> <p>So in the compile process it probably tried to compile styles.xml then saw @color so then compiled colors.xml. Or visa versa (ask Google) So it reported the error as being in colors.xml when in fast it was styles.xml/ids.xml</p> <p>And the possible error was only noticed when I saw the difference in id between the <pre><code>&lt;style name="ActionBarTitleContainer"&gt; &lt;item name="android:id"&gt;@id/title_container&lt;/item&gt; ... &lt;/style&gt; &lt;style name="ActionBarInfoContainer"&gt; &lt;item name="android:id"&gt;@+id/info_container&lt;/item&gt; ... &lt;/style&gt; </code></pre> <p>The line</p> <pre><code> &lt;item name="android:id"&gt;@+id/info_container&lt;/item&gt; </code></pre> <p>Should be (no +)</p> <pre><code> &lt;item name="android:id"&gt;@id/info_container&lt;/item&gt; </code></pre> <p>And id should be in ids.xml</p> <pre><code>&lt;resources&gt; &lt;item type="id" name="title_container" /&gt; &lt;item type="id" name="info_container" /&gt; </code></pre> <p>XML ..the punchcards of the new millenium! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload