【发布时间】: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 -->
我知道这是一个教程,我可以删除整个项目并重新开始,但我真的很想知道:
- 我哪里出错了
- 有没有更好的方法来删除项目文件而不会弄乱 AndroidManifest.xml?
谢谢!
【问题讨论】:
-
有时(
seldom,我必须说实话),不要问我为什么会这样,Eclipse 在 xml 声明之前添加了 4 个字节。这是垃圾,而且是不可见的,因为它是由不可打印的字符组成的。只需用一个像样的文本编辑器打开文件,它可以显示十六进制并删除 -
嗨@Vyger!感谢您花时间看这个。我刚刚尝试使用 hexeditor 插件在 notepad++ 中打开清单。但在那里没有看到任何额外的字节。
标签: java android android-manifest