AndroidManifest.xml is trolling me ): (AndroidManifest.xml: The markup in the document preceding the root element must be well-formed.)

StackOverflow https://stackoverflow.com/questions/22563935

  •  18-06-2023
  •  | 
  •  

سؤال

I was trying out a tutorial on http://developer.android.com/ and got stuck with an error on the AndroidManifest.xml file. What happened was, I made an error when creating the activity(made an error when keying in the "Hierachical Parent") and being new to this and all, couldn't find out how to change it. So being the newbie that I am, I deleted the Display_activiy_main.xml, Display_fragment_main and the respective .java file. I've tried some solutions here, such as commenting off the extra manifest tags, cleaning the project and CTRL+SHIFT+F. But i still get this:

[2014-03-21 23:54:47 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for C:\Users\Amos\workspace\MyFirstApp2\AndroidManifest.xml: The markup in the document preceding the root element must be well-formed.
[2014-03-21 23:54:50 - MyFirstApp2] Parser exception for /MyFirstApp2/AndroidManifest.xml: The markup in the document preceding the root element must be well-formed.
[2014-03-21 23:54:50 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for C:\Users\Amos\workspace\MyFirstApp2\AndroidManifest.xml: The markup in the document preceding the root element must be well-formed.

This is my AndroidManifest.xml

<<<<<<< Original
<<<<<<< Original

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstapp2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.myfirstapp2.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
<!-- ======= -->
<!-- <manifest xmlns:android="http://schemas.android.com/apk/res/android" > -->


<!-- <application> -->
<!-- <activity android:name="com.example.myfirstapp2.DisplayMainActivity" -->
<!-- android:label="@string/title_activity_display_main" -->
<!-- android:parentActivityName="com.example.myfirstapp2.MainActivity"> -->
<!-- <meta-data android:name="android.support.PARENT_ACTIVITY" -->
<!-- android:value="com.example.myfirstapp2.MainActivity" /> -->
<!-- </activity> -->
<!-- </application> -->


<!-- </manifest> -->
<!-- >>>>>>> Added -->


<!-- ======= -->
<!-- <manifest xmlns:android="http://schemas.android.com/apk/res/android" > -->


<!-- <application> -->
<!-- <activity android:name=".DisplayMainActivity" -->
<!-- android:label="@string/title_activity_display_main" -->
<!-- android:parentActivityName="com.example.myfirstapp2.MainActivity"> -->
<!-- <meta-data android:name="android.support.PARENT_ACTIVITY" -->
<!-- android:value="com.example.myfirstapp2.MainActivity" /> -->
<!-- </activity> -->
<!-- </application> -->


<!-- </manifest> -->

<!-- >>>>>>> Added -->

I know it's a tutorial and all, and I could just delete the whole project and start again but I really wanna know:

  1. Where did I go wrong here
  2. Is there a better way to delete project files without messing up the AndroidManifest.xml?

Thanks!

هل كانت مفيدة؟

المحلول

Where did I go wrong here

Not sure why you have this

<<<<<<< Original
<<<<<<< Original

but remove that from your manifest.xml. It shouldn't be there and isn't proper syntax for xml so you are getting the error.

Is there a better way to delete project files without messing up the AndroidManifest.xml?

Not sure what you did to cause this but it usually shouldn't be a problem. You just delete the files you don't want and sometimes you might have to delete associated resource files, Java files, etc... There is also the refactoring tool which is handy if you want to rename or move files.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top