Monday, July 2, 2012

Creating xxx.activity.out.xml and failing with Error in an XML file: aborting build.

It was very annoying when I created a basic Android activity (say activity_test.xml) and tried to run in emulator it fails with an error message stating "Error in an XML file: aborting build."

When you look in editor, you can see that it created a new blank file named activity_test.out.xml and it has an error "No XML content. Please add a root view or layout to your document."

I started playing around a little and found  that the root cause of this issue is more of an Eclipse pattern, not any error. When you click the "Run" button in Eclipse, it uses the default launch configuration registered for the selected file. What is happening is, the selected file happens to be the layout file activity_text.xml and Eclipse launches an XSL launch configuration and it fails.

Two ways to fix this issue is listed below

1) Instead of using "Run" button, select the project, right click and "Run as " > "Android Application"


2) Open Window -> Preferences -> Run/Debug -> Launching -> Launch Configurations
 Select the check box that says "Filter checked launch configuration types" and scroll down and select "XSL"
and click Apply

Make sure you delete the xxx.out.xml before you run again.

This should fix the issue. Happy Droiding!!

Blog Archive