我在最近的三个项目中遇到了一个无法调试的问题。在每个项目中每创建2-3个活动后,我得到的相同错误是:-
Parser Exception : The markup in the document preceding the root element must be well formed.此错误出现在AndroidManifest.xml文件中。
为此,我使用了Google提供的ADT Eclipse。
这个错误是可调试的,还是我必须删除项目并重新开始整个项目,直到错误再次出现?
发布于 2013-04-20 21:40:59
package="com.example.sqlitenew"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.sqlitenew.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>
发布于 2013-04-20 21:00:37
XML中的每个标签都必须包含在一个根标签中,并且所有标签都必须完全闭合。否则,它将抛出错误: error 解析器异常:文档中根元素之前的标记必须格式良好声明根标记内的元素没有正确关闭。
您的XML应采用以下格式
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<application>
<!-- activities declaration -->
</application>
</manifest>发布于 2013-04-20 22:17:30
您是否在两个操作系统之间交换项目文件?当我在linux上工作,而我的项目伙伴在windows上工作时,同样的错误也发生在我身上。尝试在XML文件中执行ctrl+shift+F。这对我很管用。
https://stackoverflow.com/questions/16120633
复制相似问题