简体   繁体   English

错误! Android中的编程-Java开发人员-根元素后的文档中的标记必须格式正确

[英]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 AndroidManifest.xml中出现以下错误

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

And my xml is : 而我的xml是:

<?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. 您已经声明了StartCameraActivity

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: 您问题中的XML包括以下几行:

    <<<<<<< Original

    </manifest>=======

and

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

The first and third would make the XML syntactically invalid; 第一个和第三个将使XML在语法上无效。 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. Android Studio支持多种设备类型,并尝试将清单与默认的移动设备类型清单合并在一起,这会导致一些类似您的问题。 I hope they have solved it with non-beta version. 我希望他们已经通过非Beta版本解决了该问题。 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. 但是合并工具,尤其是Android Studio使用的工具不能很好地工作。 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. 希望这对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:根元素后面的文档中的标记必须格式正确 - Error: The markup in the document following the root element must be well-formed 根元素后面的文档中的标记必须格式正确吗? - The markup in the document following the root element must be well-formed? Java XML 问题:文档中根元素后面的标记必须格式正确 - Java XML Problem: The markup in the document following the root element must be well-formed Android 应用程序,根元素后面的文档中的标记必须格式正确 - Android app, The markup in the document following the root element must be well-formed Eclipse错误“根元素后面的文档中的标记必须格式正确 - Eclipse error "The markup in the document following the root element must be well-formed Tomcat错误:根元素后的文档中的标记必须格式正确 - Tomcat error: The markup in the document following the root element must be well-formed 我收到此错误:根元素后面的文档中的标记必须格式正确 - i am getting this error: The markup in the document following the root element must be well-formed 添加导航抽屉会导致:根元素后面的文档中的标记必须格式正确 - Adding Navigation Drawer results in: The markup in the document following the root element must be well-formed web.xml根元素后面的文档中的标记必须格式正确 - web.xml the markup in the document following the root element must be well-formed org.xml.sax.SAXParseException 文档中根元素之后的标记必须格式正确 - org.xml.sax.SAXParseException The markup in the document following the root element must be well-formed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM