简体   繁体   中英

ERROR ! in Android - java developer - The markup in the document following the root element must be well-formed

Am getting following error in AndroidManifest.xml

The markup in the document following the root element must be well-formed.

And my xml is :

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".BasicScreenActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".StartCameraActivity"
        android:label="@string/title_activity_othar_screen" >
    </activity>
    <activity
        android:name=".GpsActivity"
        android:label="@string/title_activity_gps" >
    </activity>       
    <activity
        android:name=".SettingsActivity"
        android:label="@string/title_activity_settings" >
    </activity>
    <activity
        android:name=".HelpActivity"
        android:label="@string/title_activity_help" >
    </activity>
    <activity
        android:name=".AboutAppActivity"
        android:label="@string/title_activity_about_app" >
    </activity>
    <activity
        android:name=".HowToUseActivity"
        android:label="@string/title_activity_how_to_use" >
    </activity>
    <activity
        android:name=".AlertActivity"
        android:label="@string/title_activity_alert" >
    </activity>

</application>
</manifest>=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
    <activity
        android:name="ctic.android.screenswapper.StartCameraActivity"
        android:label="@string/title_activity_start_camera" >
    </activity>
</application>
</manifest>>>>>>>> Added

Remove the below from the manifest file

<<<<<<< Original
</manifest>=======
</manifest>>>>>>>> Added

I think this happens with eclipse ide sometimes.

Also there is no need for two manifest tag in your manifest file. Remove the duplicate. Have the below. You already have the StartCameraActivity declared.

Make sure the package names in the activity and the manifest are correct

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".BasicScreenActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".StartCameraActivity"
        android:label="@string/title_activity_othar_screen" >
    </activity>
    <activity
        android:name=".GpsActivity"
        android:label="@string/title_activity_gps" >
    </activity>       
    <activity
        android:name=".SettingsActivity"
        android:label="@string/title_activity_settings" >
    </activity>
    <activity
        android:name=".HelpActivity"
        android:label="@string/title_activity_help" >
    </activity>
    <activity
        android:name=".AboutAppActivity"
        android:label="@string/title_activity_about_app" >
    </activity>
    <activity
        android:name=".HowToUseActivity"
        android:label="@string/title_activity_how_to_use" >
    </activity>
    <activity
        android:name=".AlertActivity"
        android:label="@string/title_activity_alert" >
    </activity>
</application>
</manifest>

The XML in your question includes these lines:

    <<<<<<< Original

    </manifest>=======

and

    </manifest>>>>>>>> Added

The first and third would make the XML syntactically invalid; ie not well-formed. The second line is also probably a mistake.

It looks to me like someone has made a mistake when resolving conflict between two branches when using source code version control.

Looks like a merge conflict produced by your Version Control. Remove one of them should fix your problem

 <<<<<<< Original
 </manifest>=======
 </manifest>>>>>>>> Added

Android Studio supports various device types and tries to merge your manifest with default mobile device type manifest, it leads some problems like yours. I hope they have solved it with non-beta version. The idea is you should have a manifest structure like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ctic.android.screenswapper"
  .
  . >
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />
<application
   .
 <activity1 .....>
 <activity2 .....>
   .
   .
 </application>
</manifest>

But merge tools, especially the one that Android Studio use doesn't work well. So you should delete extra lines that came with the merge and your final manifest should look like this:

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".BasicScreenActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".StartCameraActivity"
        android:label="@string/title_activity_othar_screen" >
    </activity>
    <activity
        android:name=".GpsActivity"
        android:label="@string/title_activity_gps" >
    </activity>       
    <activity
        android:name=".SettingsActivity"
        android:label="@string/title_activity_settings" >
    </activity>
    <activity
        android:name=".HelpActivity"
        android:label="@string/title_activity_help" >
    </activity>
    <activity
        android:name=".AboutAppActivity"
        android:label="@string/title_activity_about_app" >
    </activity>
    <activity
        android:name=".HowToUseActivity"
        android:label="@string/title_activity_how_to_use" >
    </activity>
    <activity
        android:name=".AlertActivity"
        android:label="@string/title_activity_alert" >
    </activity>
    <activity
        android:name="ctic.android.screenswapper.StartCameraActivity"
        android:label="@string/title_activity_start_camera" >
    </activity>
</application>
</manifest>

I hope this one helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM