10

I recently bought a new computer and am now setting up the tools required for Android application development. I have previously installed the tools on other computers with no problem.

I find now after everything is ready for developing, that when I open an XML file for editing inside Eclipse, I receive an error: error image

If i close the tab for this XML file and then re-open it, i can edit it as expected. this happens for all XML files in my project. first time opening it there is an error, second time it is working normally.

To troubleshoot a little bit before posting here, i attempting to install different versions of eclipse. 3.4, 3.5, 3.6, all encountering the same error. I even tried installing the tools on different computers with different operating systems: windows 7 and mac os x.

I tried clearing the .metadata folder in my workspace in hopes it was some weird eclipse settings that got out of wack, no luck.

Also, after successfully opening an XML file, my editor looks like this: enter image description here

I cannot seem to view my layout in its graphical form even while in the Graphical Layout tab.

My question: How can I edit my XML files with no fuss?

  • I want the files to be opened as you would expect, and not run into these exception errors.
  • I also want to have to ability to view the Graphical Layout of my layout files.
james
  • 26,141
  • 19
  • 95
  • 113
  • I am also having exactly the same problem... – ruben Feb 19 '11 at 11:14
  • 2
    Can you confirm this behavior on a brand new project _AND_ a prior working project imported using file -> import? Thanks. – user432209 Feb 24 '11 at 17:47
  • @user432209: Hmm, Interesting though In both cases It solves the problem. I think you owe the bounty, please post this as a separate answer. THANKS! – ruben Feb 25 '11 at 22:26

4 Answers4

2

Perhaps its the same issue which was fixed by : Right click the eclipse project, click "properties", and look at "run/debug settings." Edit the settings for your project, and under "Target," make sure that an AVD is checked - see this previous question/answer

Community
  • 1
  • 1
John J Smith
  • 11,435
  • 9
  • 53
  • 72
  • 1
    Thanks for the pointing, but it still shows the error. However when I select a Platform at the upper right hand side of Graphical layout window it is gone – ruben Feb 21 '11 at 15:53
1

You could try

Project -> Clean 

or copy all your project files to a new directory without .classpath and .project and then

New -> Android Project -> From existing source

to import it

siamii
  • 23,374
  • 28
  • 93
  • 143
1

First possible explanation

Other similar problems have been reported and have to do with the SDK selection dropdown list in the layout part. Your second screenshot shows this list as being empty. Did you successfully complete the installation of the Android SDKs ?
If there is no installed SDK, the layout manager will not work as expected.
Also be aware that under certain circumstances, these packages do not install correctly from within eclipse and you have to use the android command (from the tools folder) to select and install the packages successfully.


Second possible explanation

Your eclipse workbench seems to be configured to open any XML by default as an android layout.

It is easy to check:

  • when you select an xml file in the package explorer (or some navigator), and right click on it and select the Open With option, a list of possible editors should appear within the opening submenu.
  • if the default choice is the Android Layout Editor or if the generic xml editor is absent from the list, then this is the problem.

If this is the case, then you should have a look at the xml file default editor settings in Preferences => General => Editors => File Association => *.xml and check the Android Layout Editor is not configured as the default (or the only one).

So my interpretation is that you lack a real xml editor, and that eclipse tries the Android Layout editor, because it is associated with xml files.

On top of what eclipse bundle did you install your ADT? I recommend installing on top of the Java EE bundle (that's the bulky 205MB one).

For each file, on the first attempt eclipse tries the first Android XML editor which happens to be the layout editor. When you try again it remembers that that was a failure for that file and falls back on some other editor.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Alain Pannetier
  • 9,315
  • 3
  • 41
  • 46
  • You didn't read the question well: He said 'first time opening it there is an error, second time it is working normally.' If it works normally then the layout editor is working properly. And I guess the SDK was properly installed, it is too naive. – ruben Feb 25 '11 at 22:20
  • Dear newcomer. In your comment to John Smith. you notice "when I select a Platform at the upper right hand side of Graphical layout window it is gone ". Please match this with my first explanation proposal "Your second screenshot shows this list as being empty." Sorry for being too naive. – Alain Pannetier Feb 26 '11 at 04:54
  • This empty thing is by default, It is not that no SDK is installed. When you click the box there comes all the installed platform list. But Sorry I didn't meant to heart you. At least you thought of many possibilities. – ruben Feb 26 '11 at 07:19
-2

think you should re install the Eclipse with android here are the links

1.Start Eclipse, then select Help > Install New Software....

2.Click Add, in the top-right corner.

3.In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

Click OK.

4.In the Available Software dialog, select the checkbox next to Developer Tools and click Next.

5.In the next window, you'll see a list of the tools to be downloaded. Click Next.

6.Read and accept the license agreements, then click Finish.

7.When the installation completes, restart Eclipse.

hope this will help you .

Herry
  • 7,037
  • 7
  • 50
  • 80
  • no this isn't very helpful. i have followed the installation instructions on the Android site. – james Feb 01 '11 at 15:31