无法在 Eclipse Android 项目中编辑 main.xml

发布于 2024-10-31 16:06:20 字数 1759 浏览 1 评论 0 原文

我已经在 Eclipse 中使用 ADT 创建了多个 Android 应用程序,但现在无法在新或旧 Android 项目中编辑 res/layout/main.xml。当我在 main.xml 选项卡中键入内容时,我的击键不起作用。同样,我无法在“图形布局”选项卡中进行更改。我可以将小部件拖到屏幕上,但当我放开鼠标按钮时,它不会保留。我已经通过 Eclipse 和文件系统检查过 main.xml 没有写保护。我可以通过 Eclipse 或文件系统在该目录中创建另一个文件,这表明该目录没有写保护。我在“src”目录下编辑或添加文件没有问题。

我正在 Windows 7 上运行 Eclipse Classic 3.6.1,其 Android 开发工具版本为 10.0.1.v201103111512-110841。FWIW,我最近安装了一些其他 Google 工具(GWT 和 GAE)的插件,尽管我没有使用它们任何 Android 项目(显然)。

更新:当我在不同的编辑器中编辑 xml,然后在 Eclipse 中刷新它时,出现错误“解析 XML 时出错:未绑定前缀”。我的文件是正确的,但我发现标准 URL“http://schemas.android.com/apk/res/android”无法访问。具体来说,服务器已关闭。我不知道这是否与我原来的问题有关。

Update2:这里是 foo.xml,它是我在 Eclipse 外部创建的,但在第二行显示错误 解析 XML 时出错:未绑定前缀

<?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:text="TextView" 
android:id="@+id/textView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" />

该站点 schemas.android.com 仍然处于关闭状态。

我尝试运行我的程序来获取编译器错误,但它构建正确,并且错误从 .xml 文件中消失了。去算算吧。

这仍然留下了最初的问题,即无法在 Eclipse 中编辑任何 .xml 文件。当我尝试编辑上面的 xml 文件时,我在弹出窗口中收到此错误:

No grammar constraints (DTD or XML schema) detected for the document.

我的猜测是这是由于 schemas.android .com 已关闭。

更新3(回应slund的评论):

清理和重建没有改变任何东西。我可以构建,但当我尝试编辑任一 .xml 文件时,仍然收到“无语法约束”错误。

xml 文件的目录是 C:\Users\Ellen\workspace\SqliteDemo\res\layout,正如它应该的那样。它不包含其他文件。问题视图没有显示该项目的警告或问题(尽管我的其他项目有一些警告或问题)。

更新 4

我也无法从 Eclipse 中编辑(默认)AndroidManifest.xml。

I've created several Android applications with the ADT in Eclipse, but I'm now unable to edit res/layout/main.xml in new or old Android projects. When I type in the main.xml tab, my keystrokes have no effect. Similarly, I am unable to make changes in the Graphical Layout tab. I can drag a widget onto the screen, but it does not remain when I let go of the mouse button. I have checked that main.xml is not write-protected, both through Eclipse and the file system. I am able to create another file in that directory, through either Eclipse or the file system, which shows that the directory is not write-protected. I have no problem editing or adding files under the "src" directory.

I am running Eclipse Classic 3.6.1 with version 10.0.1.v201103111512-110841 of the Android Development Tools on Windows 7. FWIW, I recently installed plugins for some other Google tools (GWT and GAE), although I did not use them for any of the Android projects (obviously).

Update: When I edit the xml in a different editor and then refresh it in Eclipse, I get the error "Error parsing XML: unbound prefix". My file is correct, but I discovered that the standard URL "http://schemas.android.com/apk/res/android" is unreachable. Specifically, the server is down. I don't know if this is related to my original problem.

Update2: Here is foo.xml, which I created outside of Eclipse but is showing the error Error parsing XML: unbound prefix on the second line:

<?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:text="TextView" 
android:id="@+id/textView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" />

The site schemas.android.com is still down.

I tried running my program to get the compiler errors, but it build correctly, and the error went away from the .xml file. Go figure.

That still leaves the original problem of not being able to edit any .xml file within Eclipse. When I tried to edit the above xml file, I got this error in a popup:

No grammar constraints (DTD or XML schema) detected for the document.

My guess is that this is due to schemas.android.com being down.

Update 3 (in response to slund's comment):

Cleaning and rebuilding did not change anything. I could build, but I still got the "No grammar constraints" error when I tried editing either .xml file.

The directory of the xml files is C:\Users\Ellen\workspace\SqliteDemo\res\layout, just as it should be. It contains no other files. The Problem view showed no warnings or problems for this project (although there were some for other projects of mine).

Update 4

I also cannot edit the (default) AndroidManifest.xml from within Eclipse.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ぶ宁プ宁ぶ 2024-11-07 16:06:20

在遵循 Android 资源网站上的初学者教程后,我遇到了同样的问题 - 只需在标记 (http://developer.android.com/resources/tutorials/views/index.html) 中创建一个布局并删除 textview 元素。

现在切换回图形布局模式,一切都应该正常工作!

I had the same issue after following the beginner tutorials on the Android resource site - simply create a layout in the markup (http://developer.android.com/resources/tutorials/views/index.html) and remove the textview element.

Now switch back to graphical layout mode and everything should work fine!

极度宠爱 2024-11-07 16:06:20

我有一个类似的问题(在 Windows 7 中)。关闭索引和防病毒解决了我的问题。

I had a similar issue (in windows 7). Turning off indexing and antivirus solved my problem.

心病无药医 2024-11-07 16:06:20

我最近刚刚遇到这个问题。由于这里没有公认的答案,所以我会猜测一下。

我认为这与xml中指定的版本有关。我不完全确定你的情况,但是,也许你可以验证我的说法。 Eclipse 主要版本是否与您的 xml 文件中指定的版本匹配?

例如,在 Eclipse Kepler (4.3) 中打开以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin
   id="com.someplace.something"
...

我也无法编辑它。然而,在 Eclipse Indigo (3.7) 中打开相同的plugin.xml 似乎可以让我很好地编辑该文件。因此,Eclipse 主要版本必须匹配。

我没有深入研究 Eclipse 文档来验证这一点。所以,在这一点上,我只是将此称为对根本原因的预感。

对于遇到此问题的任何人,如果您确实坚持在 Eclipse 中编辑 xml 文件,那么您可能需要在 xml 中指定正确的主要版本。不幸的是,保留旧版本的 Eclipse 并不是最理想的解决方案! ;-)

I just recently ran into this problem. Since there is no accepted answer here, I'll give it a guess.

I believe that this has something to do with the version specified in the xml. I'm not entirely sure in your case, but, perhaps you can verify my claim. Does the eclipse major version match what is specified in your xml file?

For instance, opening the following in Eclipse Kepler (4.3):

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin
   id="com.someplace.something"
...

I was unable to edit it, as well. However, opening the same plugin.xml in Eclipse Indigo (3.7) seemed to allow me to edit the file just fine. So, the Eclipse major version must match.

I didn't dig too deep to verify this in the Eclipse documentation. So, at this point, I'm just calling this a hunch as to the root cause.

For anyone who runs into this issue, if you really insist upon editing the xml file in Eclipse, then you might require the proper major version specified in the xml. Unfortunately, keeping old versions of Eclipse around isn't the most ideal solution! ;-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文