Error parsing XML: no element found
Asked Answered
E

4

11

First off forgive me if I posted this question wrong. I've used stackoverflow for many problems but this is the first time I couldnt already find an answer to my problem. So, if I'm doing something wrong please let me know and I'll repost / edit the question.

Now unto business. I've just recently started development w/ the Android SDK and I'm following the basic tutorial from http://developer.android.com/resources/tutorials/hello-world.html#avd I've gotten up the xml editting part and when I make all the changes to the xml files main.xml and strings.xml this error occurs. Also, when I compile the project, the compilation process generates a main.out.xml file that is empty. I don't know what it is or its purpose.

The error:

[2011-12-30 16:10:02 - Hello Razor] res\layout\main.xml:0: error: Resource entry main is already defined. [2011-12-30 16:10:02 - Hello Razor] res\layout\main.out.xml:0: Originally defined here. [2011-12-30 16:10:02 - Hello Razor] C:\Users\Dux69\workspace\Hello Razor\res\layout\main.out.xml:1: error: Error parsing XML: no element found [2011-12-30 16:10:13 - Hello Razor] Error in an XML file: aborting build.

My project is setup for platform: Android 2.3.3 API Level: 10

I don't know if it makes a difference or not but I'm using my Android Incredible for running/debugging the application not a Android Virtual Device. If there is any more information needed let me know and I'll post it ASAP.

Here are the three code files I'm using:

main.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:text="@string/hello_O" />

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_O">Baba in the house, Razor Activity!</string>
<string name="app_name">Hello Razor App</string>
</resources>

razorActivity.java

package hello.Razor;

import android.R;
import android.app.Activity;
import android.os.Bundle;

    public class razorActivity extends Activity
    {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
        }
    }
Exemption answered 30/12, 2011 at 23:20 Comment(0)
D
4

I had a similar problem once.

Rebuilding/cleaning the project and restarting Eclipse helped for me.

Dworman answered 30/12, 2011 at 23:33 Comment(1)
I was facing this in xamarin studio by cleaning and rebuilding it did resolve.!Propaedeutic
R
4

delete the main.out.xml in project view and re-run as android application

Roselleroselyn answered 30/12, 2011 at 23:45 Comment(4)
if doesn't works, delete main.out.xml and do a Clean, then open your razorActivity.java and re-run. It's a common aapt errorRoselleroselyn
wow thanks for the help. I have to go through a whole process of shutting down eclipse, re-opening it, deleting that file, and then cleaning. What a hassle man. Is there anyway that I can fix this?Exemption
when you the first time tried to "Run" your application you were executing the XML file (strange behaviour from eclipse i understand you), so when you run the app it launches again and again the XML file due the fact it's the first in your history run.. Just delete, open your razorActivity.java and launch from Run -> Run History and it should be finally fixed foreverRoselleroselyn
Thanks for the feedback, Riccardo Bocci and others. Now that I understand this nuisance maybe now I can start some actual android programming!Exemption
J
1

Error message I got:

Error:(43) Error parsing XML: no element found

and

Error:Execution failed for task ':app:processDebugResources'.

com.android.ide.common.process.ProcessException: Failed to execute aapt

Solution: In my case, project activity_main.xml is initiated with the code

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.batvibes.battybirthday.Main1Activity">

and I forgot the below end tag.

</android.support.constraint.ConstraintLayout>

Disclaimer: I am totally new to android development. My suggestion, please check all tags opening and closing and go to next step of debugging.

Jansson answered 25/3, 2017 at 23:7 Comment(0)
R
1

Try to end your Main or Sub Layout like:

</LinearLayout>
Resiniferous answered 22/4, 2018 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.