0

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!

cookiedookie
  • 389
  • 1
  • 5
  • 17
  • **Sometimes** (`seldom`, I must be honest), don't ask me why it happens, Eclipse adds 4 bytes before the xml declaration. This is garbage, and it's invisible, because it's made of unprintable characters. Just open the file with a decent text editor that can show you hex and remove the 4 bytes before – Phantômaxx Mar 21 '14 at 16:24
  • Hi @Vyger ! Thanks for taking time to look at this. I've just tried opening the manifest in notepad++ with the hexeditor plugin. But didn't see any extra bytes there. – cookiedookie Mar 21 '14 at 16:40

1 Answers1

2

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.

codeMagic
  • 44,549
  • 13
  • 77
  • 93
  • Hi @codeMagic ! Thanks for your quick response! I've tried deleting it and now I am getting this `code`[2014-03-22 00:20:49 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for C:\Users\Amos\workspace\MyFirstApp2\AndroidManifest.xml: The processing instruction target matching "[xX][mM][lL]" is not allowed.`code` What does it mean? – cookiedookie Mar 21 '14 at 16:23
  • seems a conflict from svn. – Blackbelt Mar 21 '14 at 16:26
  • @AmosCEOcookie that looks like a separate issue not related to your code. Without more information, I don't know exactly what is causing that. Maybe an svn issue, as blackbelt said. – codeMagic Mar 21 '14 at 16:27
  • @codeMagic Okay, i've tried cleaning it again and formatting the file And now, the errors are gone! I guess this is one of those weird areas of java/eclipse where the '1's and '0's decide not to work out. Nevertheless, Thanks for your help!! – cookiedookie Mar 21 '14 at 17:20