11

首先,如果我错误地发布了这个问题,请原谅我。我用 stackoverflow 解决了很多问题,但这是我第一次找不到问题的答案。所以,如果我做错了什么,请告诉我,我会重新发布/编辑问题。

现在开始做生意。我最近刚刚开始使用 Android SDK 进行开发,我正在遵循http://developer.android.com/resources/tutorials/hello-world.html#avd的基本教程 我已经开始了 xml 编辑部分,当我对 xml 文件 main.xml 和 strings.xml 进行所有更改时,会发生此错误。另外,当我编译项目时,编译过程会生成一个空的 main.out.xml 文件。我不知道它是什么或它的目的。

错误:

[2011-12-30 16:10:02 - Hello Razor] res\layout\main.xml:0:错误:资源条目 main 已定义。[2011-12-30 16:10:02 - Hello Razor] res\layout\main.out.xml:0:最初定义在这里。[2011-12-30 16:10:02 - Hello Razor] C:\Users\Dux69\workspace\Hello Razor\res\layout\main.out.xml:1: 错误:解析 XML 时出错:找不到元素 [2011 -12-30 16:10:13 - Hello Razor] XML 文件中的错误:正在中止构建。

我的项目是为平台设置的:Android 2.3.3 API 级别:10

我不知道它是否有所作为,但我正在使用我的 Android Incredible 来运行/调试应用程序而不是 Android 虚拟设备。如果需要更多信息,请告诉我,我会尽快发布。

这是我正在使用的三个代码文件:

主要的.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:text="@string/hello_O" />

字符串.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_O">Baba in the house, Razor Activity!</string>
<string name="app_name">Hello Razor App</string>
</resources>

razorActivity.java

package hello.Razor;

import android.R;
import android.app.Activity;
import android.os.Bundle;

    public class razorActivity extends Activity
    {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
        }
    }
4

4 回答 4

4

我曾经遇到过类似的问题。

重建/清理项目并重新启动 Eclipse 对我有帮助。

于 2011-12-30T23:33:09.927 回答
4

删除项目视图中的 main.out.xml 并作为 android 应用程序重新运行

于 2011-12-30T23:45:51.487 回答
1

我得到的错误信息:

Error:(43) Error parsing XML: no element found

Error:Execution failed for task ':app:processDebugResources'.

com.android.ide.common.process.ProcessException:无法执行 aapt

解决方案:在我的情况下,项目 activity_main.xml 是用代码启动的

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.batvibes.battybirthday.Main1Activity">

我忘记了下面的结束标签。

</android.support.constraint.ConstraintLayout>

免责声明:我对 android 开发完全陌生。我的建议,请检查所有打开和关闭的标签,然后进行下一步调试。

于 2017-03-25T23:07:23.870 回答
1

尝试结束您的主布局或子布局,例如:

</LinearLayout>
于 2018-04-22T11:50:15.170 回答