AndroidManifest.xml 文档中跟在根元素之后的标记必须格式正确

标签 android xml

我已经让 Eclipse 生成一个基本的 android Hello World 应用程序,但它有 2 个错误:首先,在我的 AndroidManifest.xml 中的这两行:
我得到 The markup in the document following the root element must be well formed,而且无论我清理我的项目多少次,我的 R.java 都不会生成。有答案吗?

list 在这里:http://jsfiddle.net/NHDU6/

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="15" />

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

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


<!--
     Declare the contents of this Android application.  The namespace
     attribute brings in the Android platform namespace, and the package
     supplies a unique name for the application.  When writing your
     own application, the package name must be changed from "com.example.*"
     to come from a domain that you own or have control over.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jfkingsley.maclogin" >

    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.SET_WALLPAPER" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />

    <application
        android:icon="@drawable/ic_launcher_home"
        android:label="@string/home_title" >
        <activity
            android:name="Home"
            android:launchMode="singleInstance"
            android:stateNotNeeded="true"
            android:theme="@style/Theme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="Wallpaper"
            android:icon="@drawable/bg_android_icon"
            android:label="Wallpaper" >
            <intent-filter>
                <action android:name="android.intent.action.SET_WALLPAPER" />

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

</manifest>

谢谢,乔纳森

最佳答案

这是你的 list ,

您不应指定多个 Manifest并且您不应指定多个 <application>标签。

 <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.jfkingsley.maclogin" >

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

    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.SET_WALLPAPER" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="h" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="Home"
            android:launchMode="singleInstance"
            android:stateNotNeeded="true" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="Wallpaper"
            android:icon="@drawable/ic_launcher"
            android:label="Wallpaper" >
            <intent-filter>
                <action android:name="android.intent.action.SET_WALLPAPER" />

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

</manifest>

关于AndroidManifest.xml 文档中跟在根元素之后的标记必须格式正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11668372/

相关文章:

java - 从 Android 应用程序发送电子邮件

java - 应用程序显示空白屏幕但预览看起来不错

android - 如何将按钮放在 Activity 标题中?

android.widget.SeekBar 无法转换为 android.widget.TextView

c# - 使用 xsl 样式表的前三行 xml 文档的正确内容

java - 如何修复错误 "org.xml.sax.SAXParseException/Content is not allowed in prolog"?

java - 如何避免 Android Webview 内部错误?

c# - 使用 LINQ 覆盖或忽略 C# 中未声明的实体

android - 可滚动寻呼适配器

java - 为什么当我创建一个新 Activity 时, "setContentView"无法识别我的布局?