【问题标题】:Error in AndroidManifest.xml while making "My First App" from developer.android.com从 developer.android.com 制作“我的第一个应用程序”时 AndroidManifest.xml 出错
【发布时间】:2013-01-02 22:35:38
【问题描述】:

我正在通过 developer.android.com 上的培训学习 Android 开发,并且我已经完成了“开始另一个活动”。当我尝试运行我的代码时,我在 AndroidManifest.xml 中收到以下错误:

错误:解析 XML 时出错:XML 或文本声明不在实体开头

我想我没有在 AndroidManifest.xml 上编辑一行,因为我使用的是 Eclipse IDE,并且不需要自己创建标签。这是我的 AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
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.myfirstapp.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>
    <activity
        android:name="com.example.myfirstapp.DisplayMessageActivity"
        android:label="@string/title_activity_display_message"
        android:parentActivityName="com.example.myfirstapp.MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.myfirstapp.MainActivity" />
    </activity>
</application>

</manifest>

错误显示在第一行代码中。请帮忙。

【问题讨论】:

  • 这是完整的 AndroidManifest.xml 文件。我也应该添加其他文件吗?它们与 Android 开发者培训中的相同。

标签: android xml eclipse android-manifest


【解决方案1】:

您的项目未正确刷新,这就是显示错误的原因

在日食中Project--&gt;Clean位置

然后只需清理并构建您的项目。

【讨论】:

  • 在activity_main.xml中添加了Linear Layout标签。这是清单文件。
【解决方案2】:

错误可能是因为你的布局文件

完成XML中的每一个标签

喜欢这个

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:orientation="vertical">

 <TextView android:id="@+id/text1"
     android:textSize="16sp"
     android:textStyle="bold"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"/>

 <TextView android:id="@+id/text2"
     android:textSize="16sp"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"/>
 </LinearLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    相关资源
    最近更新 更多