【问题标题】:AndroidManifest.xml is trolling me ): (AndroidManifest.xml: The markup in the document preceding the root element must be well-formed.)AndroidManifest.xml 在欺骗我):(AndroidManifest.xml:根元素之前的文档中的标记必须格式正确。)
【发布时间】:2014-05-10 12:47:53
【问题描述】:

我正在尝试关于 http://developer.android.com/ 的教程 并在 AndroidManifest.xml 文件中遇到错误。发生的事情是,我在创建活动时出错(在键入“分层父级”时出错)并且对这一切都是新手,无法找到如何更改它。所以作为我的新手,我删除了 Display_activiy_main.xml、Display_fragment_main 和相应的 .java 文件。我在这里尝试了一些解决方案,例如注释掉额外的清单标签、清理项目和 CTRL+SHIFT+F。但我还是明白了:

[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.

这是我的 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 -->

我知道这是一个教程,我可以删除整个项目并重新开始,但我真的很想知道:

  1. 我哪里出错了
  2. 有没有更好的方法来删除项目文件而不会弄乱 AndroidManifest.xml?

谢谢!

【问题讨论】:

  • 有时seldom,我必须说实话),不要问我为什么会这样,Eclipse 在 xml 声明之前添加了 4 个字节。这是垃圾,而且是不可见的,因为它是由不可打印的字符组成的。只需用一个像样的文本编辑器打开文件,它可以显示十六进制并删除
  • 嗨@Vyger!感谢您花时间看这个。我刚刚尝试使用 hexeditor 插件在 notepad++ 中打开清单。但在那里没有看到任何额外的字节。

标签: java android android-manifest


【解决方案1】:

我哪里错了

不知道为什么会有这个

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

但将其从您的 manifest.xml 中删除。它不应该存在并且不是 xml 的正确语法,因此您会收到错误消息。

有没有更好的方法可以在不弄乱 AndroidManifest.xml 的情况下删除项目文件?

不确定您做了什么导致此问题,但通常应该不是问题。您只需删除您不想要的文件,有时您可能不得不删除关联的resource 文件、Java 文件等...如果您想重命名或移动文件,还有重构工具非常方便。

【讨论】:

  • 嗨@codeMagic!谢谢你快速的回复!我试过删除它,现在我得到了这个code[2014-03-22 00:20:49 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] C:\Users 的解析器异常\Amos\workspace\MyFirstApp2\AndroidManifest.xml:处理指令目标匹配“[xX][mM][lL]”是不允许的。code是什么意思?
  • 似乎与 svn 有冲突。
  • @AmosCEOcookie 看起来像一个与您的代码无关的单独问题。没有更多信息,我不知道究竟是什么原因造成的。正如 blackbelt 所说,可能是一个 svn 问题。
  • @codeMagic 好的,我已经尝试再次清理它并格式化文件现在,错误消失了!我想这是 java/eclipse 中 '1' 和 '0' 决定不起作用的那些奇怪领域之一。不过,感谢您的帮助!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多