0

我正在尝试创建我的第一个 Android 应用程序。我正在使用 Eclipse。我创建了一个项目,在我自己添加任何代码之前,我运行了默认项目,并在我的模拟器中获得了“Hello,MyApp”。

都好。

然后,我将一个按钮拖放到我的“avtivity”上,在我创建项目时添加的文本下。

突然,XML 错误!

[2012-06-02 18:03:48 - FuelLogger] res\layout\main.xml:0: error: Resource entry main is already defined.
[2012-06-02 18:03:48 - FuelLogger] res\layout\main.out.xml:0: Originally defined here.
[2012-06-02 18:03:48 - FuelLogger] D:\Android\eclipse\Workspace\res\layout\main.out.xml:1: error: Error parsing XML: no element found
[2012-06-02 18:03:49 - FuelLogger] Error in an XML file: aborting build.

它创建了一个新文件 main.out.xml

那是什么?它是空的。

我的 main.xml 看起来像这样:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

如果我查看“图形布局”选项卡,它看起来不错...

我显然在这里遗漏了一些东西。希望有人可以提供帮助。

4

4 回答 4

2

我认为您已经选择了 main.xml 并在代码窗口中进行了操作;然后你按下 Eclipse 的 RUN 按钮。这会产生错误。

首先: DELETE : main.out.xml 从你的 res\layout\ 文件夹然后

运行项目:

打开“项目资源管理器”

右击您的项目,

单击运行 AS

点击安卓应用

于 2012-06-02T08:16:16.257 回答
1

从 res/layout 文件夹中删除 main.xml.out 文件,然后清理并构建/运行应用程序。如果您无法从 Eclipse 中删除该文件,请将其从您的工作区中删除,然后清理并构建/运行应用程序

于 2012-06-02T08:17:37.963 回答
1

删除main.out.xml,清理后作为Android应用运行。 这是详细描述 类似问题的答案:main-out-xml-parsing-error

于 2012-06-02T08:18:33.560 回答
0

你也可能想看看这里。似乎与您的问题有关, main.out.xml 是造成问题的原因......

于 2012-06-02T08:17:45.470 回答