简体   繁体   English

Eclipse帮助新用户

[英]Eclipse help for brand new user

I am trying to create my first Android app. 我正在尝试创建我的第一个Android应用。 I am using Eclipse. 我正在使用Eclipse。 I create a project, and before I add any code myself, I run the default project, and I get the 'Hello, MyApp' in my emulator. 我创建一个项目,然后自己添加任何代码,然后运行默认项目,并在模拟器中获得“ Hello,MyApp”。

All good. 都好。

I then drag and drop a button onto my 'avtivity', under the text that was added when I create the project. 然后,在创建项目时添加的文本下方,将一个按钮拖放到“活动性”上。

Suddenly, XML errors! 突然,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.

It has created a new files, main.out.xml 它创建了一个新文件main.out.xml

What's that? 那是什么? It's empty. 它是空的。

My main.xml looks like this: 我的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>

If I look at the 'Graphical Layout' tab, it looks fine... 如果我查看“图形布局”选项卡,看起来很好...

I am obviously missing something here. 我显然在这里错过了一些东西。 Hope someone can help. 希望有人能帮忙。

I think you have selected your main.xml and is oped in code window; 我认为您已经选择了main.xml并在代码窗口中选择了它; then you r pressing RUN button of eclipse. 然后您按Eclipse的RUN按钮。 Which creates error. 这会产生错误。

First of All: DELETE : main.out.xml From your res\\layout\\ folder Then 首先:DELETE:main.out.xml从您的res \\ layout \\文件夹中然后

To run project: 运行项目:

Make open "Project Explorer" 打开“项目资源管理器”

Rigth Click on Your Project, Rigth单击您的项目,

Click Run AS 单击运行方式

Click Android Application 点击Android应用

Delete the main.xml.out file from your res/layout folder and the clean and build/run the application. 从res / layout文件夹中删除main.xml.out文件,然后清理并构建/运行该应用程序。 If you are not able to delete the file from eclipse delete it from your workspace and the clean and build/run the application 如果您无法从Eclipse中删除文件,请从工作空间中删除它,然后清理并生成/运行该应用程序

Delete main.out.xml, and run as Android application after cleaning. 删除main.out.xml,并在清理后作为Android应用程序运行。 Here is detailed description Similar problem answers: main-out-xml-parsing-error 这里是详细说明类似问题的答案: main-out-xml-parsing-error

also you might want to look here . 你也可能想看这里 Seems related to your question, that main.out.xml is what's causing the trouble... 似乎与您的问题有关,main.out.xml是引起问题的原因...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM