【问题标题】:Eclipse help for brand new user新用户的 Eclipse 帮助
【发布时间】:2012-06-02 16:18:33
【问题描述】:

我正在尝试创建我的第一个 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>

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

我显然在这里遗漏了一些东西。希望有人能帮忙。

【问题讨论】:

  • 看看This
  • 尝试清理您的项目。菜单来源 > 清理。

标签: android eclipse


【解决方案1】:

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

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

运行项目:

打开“项目资源管理器”

右击您的项目,

点击运行AS

点击安卓应用

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 谢谢先生!这是解决方案的一部分。谢谢!
    【解决方案3】:

    删除main.out.xml,清理后作为Android应用运行。 Here is detailed description 类似问题解答:main-out-xml-parsing-error

    【讨论】:

    • 谢谢!这是解决方案的一部分。
    【解决方案4】:

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

    【讨论】:

      猜你喜欢
      • 2011-02-01
      • 2014-07-27
      • 1970-01-01
      • 2016-10-10
      • 1970-01-01
      • 2013-09-14
      • 1970-01-01
      • 1970-01-01
      • 2016-01-31
      相关资源
      最近更新 更多