‘Error parsing XML: no element found’ message in Eclipse Android project
Question:I have an Android project with Eclipse. When I click on the ‘Run’ toolbar icon, the Eclipse is building a file: main.out.xml and fails to run my app. The error message is: main.out.xml:1: error: Error parsing XML: no element found, or res/layout/main.xml:0: error: Resource entry main is already defined. My code is error free but I can’t build and run it. I can’t figure it out.
Answer: In Android projects Eclipse does not “know” how to start your app. Probably you opened an xml file, namely main.xml, and kept it open and active when you clicked on the Run button. In this case the IDE wanted to execute it and created the main.out.xml file.
1. Delete main.out.xml
2. Clean your project (Project -> Clean…)
3. Click on one of your .java source code files (open it)
4. Click on Run. It will work now.
5. Drink a tea while waiting for the emulator to launch your Android app. It may take 2-3 minutes for the first time.
6. Next time avoid executing any xml file.
7. There are helpful options among preferences. Navigate to Eclipse -> Preferences. Select Run/Debug on the left navigation pane. Go to Launching.
a./ At the Preferences tab go down to the ‘Launch Operation’ group. Click on ‘Always launch the previously launched application’.
b./ On the left list select Launch Configuration. Check ‘Filter checked launch configuration types’. Go down to XSL and check it.