Cannot edit main.xml in Eclipse Android project
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 f开发者_运维问答or this project (although there were some for other projects of mine).
Update 4
I also cannot edit the (default) AndroidManifest.xml from within Eclipse.
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!
I had a similar issue (in windows 7). Turning off indexing and antivirus solved my problem.
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! ;-)
精彩评论