eclipse 元素类型“活动”必须后跟属性规范,“>”或“/>”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20760102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Element type "activity" must be followed by either attribute specifications, ">" or "/>"
提问by theRenaissanceMan
I've read up on forum posts about similar errors, but nothing I read works. It looks like my formatting is fine, but I keep getting the indicated error. I've tried refreshing the project and cleaning the project as well as restarting Eclipse entirely.
我已经阅读了有关类似错误的论坛帖子,但我读到的任何内容都不起作用。看起来我的格式没问题,但我一直收到指示的错误。我尝试刷新项目并清理项目以及完全重新启动 Eclipse。
<manifest
... >
<application
... >
<activity
android:name="com.myNamespace.myPackage.MainActivity"
android:label="@string/app_name">
</activity>
</application>
</manifest>
回答by GrIsHu
In your manifest you must have forget to close one of the attribute. Check out your manifest file closely and make sure you have closed all the tags.
在您的清单中,您必须忘记关闭属性之一。仔细检查您的清单文件并确保您已关闭所有标签。
回答by shrikant
I also faced the same isssue but I found that it was coming because of copying and pasting the code in xml file.
我也遇到了同样的问题,但我发现它是由于在 xml 文件中复制和粘贴代码而导致的。
Please try to type the code manually and see. Hope the error will not come.
请尝试手动键入代码并查看。希望错误不会出现。
回答by user3106633
try like this
像这样尝试
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myNamespace.myPackage"
android:versionCode="12" android:versionName="2.2.0">
<uses-sdk android:minSdkVersion="3" />
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
<activity android:name="com.myNamespace.myPackage.MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
回答by MS111
I had the same error until I figured out that the activity tag needs to open and close on the same line. It's not a written syntax but my error was gone when I wrote the whole tag in one line instead of on separate lines. You should try it like this:
我遇到了同样的错误,直到我发现活动标签需要在同一行上打开和关闭。这不是书面语法,但是当我在一行中而不是在单独的行中编写整个标签时,我的错误消失了。你应该像这样尝试:
<application>
<activity android:name=".MainActivity" android:label="@string/app_name"> </activity>
</application>
</manifest>
回答by Vincent
I develop in Eclipse on a Mac. When I copy items (both from within Code and/or from a webpage (like Stackoverflow or so) I often get this error. I believe that the copy/paste mechanism is not functioning completely well.
我在 Mac 上的 Eclipse 中开发。当我复制项目(从代码和/或网页(如 Stackoverflow 等)复制项目时,我经常收到此错误。我认为复制/粘贴机制不能完全正常运行。
What I do to solve this error, is just typing the complete line (no copy/paste!), all over again.
我为解决这个错误所做的只是重新输入完整的行(没有复制/粘贴!)。
When I have copied a block I see that the error moves to the next line, which you have to retype also.
当我复制一个块时,我看到错误移动到下一行,您也必须重新输入。
Very time consuming and frustrating, but this really works!
非常耗时且令人沮丧,但这确实有效!