java - AndroidManifest.xml 正在欺骗我): (AndroidManifest. xml : The markup in the document preceding the root element must be well-formed.)

标签 java android android-manifest

我正在尝试 http://developer.android.com/ 上的教程 并在 AndroidManifest.xml 文件上遇到错误。发生的事情是,我在创建 Activity 时犯了一个错误(在键入“层次结构父级”时犯了一个错误)并且对这一切都是新手,无法找到如何更改它。因此,作为新手,我删除了 Display_activiy_main.xml、Display_fragment_main 和相应的 .java 文件。我在这里尝试了一些解决方案,例如注释掉额外的 list 标签、清理项目和 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?

谢谢!

最佳答案

Where did I go wrong here

不知道为什么你有这个

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

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

Is there a better way to delete project files without messing up the AndroidManifest.xml?

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

关于java - AndroidManifest.xml 正在欺骗我): (AndroidManifest. xml : The markup in the document preceding the root element must be well-formed.),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22563935/

相关文章:

android - INFO 暂时找不到正在跳过的测试类 SampleTest

android - Fabric 不接受 @string/... 对其在 manifest.xml 中的 API key 的引用

java - 如何下载和使用jface

Java 错误地解析了一些日期,即使它们是有效的

java - 从 Java 中的多个方法获取用户输入的最佳实践?

java - Android Manifest 又该如何合并?

Android:应用程序因后台位置而被 Google 拒绝

java - 是否可以避免在 For 循环中创建 java.sql.Date 对象

java - 如何使用 Dagger2 绑定(bind)到具有多个 ViewModelFactory 的 map

android - 将 Android App Bundle 上传到 Google Play 控制台 - key 签名错误