【发布时间】: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
-
尝试清理您的项目。菜单来源 > 清理。