18

Possible Duplicate:
Moving and vanishing lines of code; trouble with Eclipse's XML Editor

I'm new to Eclipse and ADT but have set up my environment on two different machines, and both are displaying the same oddities (both are Windows 7 64 bit).

When changing tabs between the graphical layout and the main.xml views, the lines of code in the main.xml view will start disappearing or moving around. It's hard to display this without a video or animated gif, but I'll attempt with these screenshots:

Note that all I've done is highlight a block of text, and suddenly all these artifacts shwo up. It makes development a bit less than pleasant.

Any thoughts? Please Help me to solve this problem.

images :

Image1 Image2

Community
  • 1
  • 1
user1089679
  • 2,328
  • 8
  • 41
  • 51
  • 2
    I have experienced this as well. The problem is intermittent, sometimes it happens, sometimes it does not. I think its a glitch of eclipse. Just an opinion. – BearDroid May 31 '12 at 02:45
  • @pyuro ca i solve this problem using old version ADT and Eclipse? Please Let me know because of this problem i havent do anything in my application. its too hard to entertainment this problem – user1089679 May 31 '12 at 03:46
  • Sounds ike http://bugs.eclipse.org/375421 , but so far, NO ONE has given us reliable steps to reproduce it. They've complained about it here, and on YouTube, and finally with some prodding, in a bug report, but all of it without steps to reproduce it so it can actually be fixed. – nitind May 31 '12 at 04:55
  • you can always close the opened file(closing the tab), then reopen it. Just don't save any changes made to the file before closing when this problem arises. That's what I do when faced with this problem, other than that, I cant give you any more advice. – BearDroid May 31 '12 at 06:03
  • @nitind we can resolved it how? Eclipse has to provide some solution for this. can i avoid this tihng using lower version of ADT and Eclipse? – user1089679 May 31 '12 at 08:12
  • @user1089679 I don't know. As I said, no one's given us steps to intentionally and reliably cause the problem to happen so we can actually fix it. – nitind Jun 02 '12 at 06:02
  • I get this problem consistently, please let me know what you need in terms of a bug report and I'll feedback. – Oliver Pearmain Aug 01 '12 at 15:07
  • @HaggleLad Repeatable well-described steps to force the problem to happen at will would help us figure out where things are going wrong. – nitind Sep 03 '12 at 00:41
  • Here's one more hoping this gets fixed. It happens all the time and I'm running the latest Eclipse/ADK. I usually fix it by pressing undo to whatever the visual editor does that breaks stuff, then change the XML by hand to what it needs to be :) The answer below about wrong newlines makes sense! – Glebbb Sep 12 '12 at 04:52

7 Answers7

13

FOUND AN EASY WAY TO DISABLE THE BUG!! (WORKAROUND)

Window > Preferences > Android > Editors > Untick "Format XML files using the standard..." (1st option)

Then, just do Ctrl + Shift + F to Auto-format your XML to Eclipse Built-In convention. You should not be getting the bug at all.

tom_mai78101
  • 2,383
  • 2
  • 32
  • 59
  • I think this is it! The ultimate workaround. However if someone can't live without android attribute sorting, formatting and such, he can use my workaround (in my answer), it's working for me so far. – sidon Sep 13 '12 at 09:21
  • Please do this as a favor: Spread the word about this! :D Thanks in advance! – tom_mai78101 Sep 13 '12 at 13:24
  • I get it everytime I delete a tag from the xml! so annoying – user1940676 Nov 19 '13 at 15:57
12

I had this problem my self, when the xml editor does this "thing" go to source->cleanup document, I kept the checkboxes on the dialog at their default (all checked except "convert line delimiters to...") and press ok.

that solved it for me. hope it helps.

eleonzx
  • 677
  • 10
  • 16
  • Strangely, leaving only "convert line delimiters to windows" is working for me. I don't like the formatting that this dialog does so I use default formatting (Ctrl+Shift+F). Formatting and than converting line delim. is working every time, but I'm looking for more general solution to this. – sidon Sep 11 '12 at 08:24
  • Also the more faster way for me is to use File > Convert Line Delimiters To > Windows (0D0A) – sidon Sep 11 '12 at 08:43
  • `TO RECREATE THE PROBLEM EASILY: 1. Go switch the tab in your XML Wizard to display the source code. 2. Purposefully add/edit something in your XML code, so that it generates a yellow warning swiggly underline. Three is enough. 3. While the yellow warning(s) are displayed, switch over to the Graphical Layout, and back to Source tab. 4. You should be able to highlight all the text up and down with your mouse and see the bug. OPTIONAL: If you want to visually see the bug, try Window > Preferences > General > Editors > Text Editors > Tick "Show Line Numbers"` – tom_mai78101 Sep 12 '12 at 14:04
1

I also had same problem and I think closing the file and opening it after clean again is the only solution.

I have found that this problem is only with Eclipse Indigo.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Chandrashekhar
  • 498
  • 4
  • 19
1

I had the same problem. What I did was deleted Eclipse and ADT. Then upgraded to Juno. The new combination seemd to fix it for me. I think its a problem with the new ADT and Indigo.

Shaun
  • 5,483
  • 10
  • 40
  • 49
  • 1
    I did try to install Juno and download ADT into it, but the problem persists. Although I did not delete the old version of eclipse. But Eclipse doesn't really have installer. It is just copying file to disk. I used classic Eclipse package (http://www.eclipse.org/downloads/packages/eclipse-classic-42/junor) 32bit for windows, what package did you use? – sidon Sep 10 '12 at 14:21
  • Im using the x64 package. The old Eclipse wont mess with your new eclipse as it doesnt really use any shared settings. I dont know what the problem would be then – Shaun Sep 10 '12 at 18:23
1

Working solution for me is to convert line delimiters to Unix (LF, \n, 0A) for the xml layout file. (File > Convert Line Del. To > Unix) This need to be done only once. I didn't change default line ending in settings.

The ADT is not messing up the code any longer, and while editing xml manually, eclipse is smart enough to use Unix new line character for this file even if I have windows new line character set as default.

Origin of the problem:

The problem was that ADT inserted wrong new line characters. Eg. there was "\r\n\r\r\n" between the lines of code. Notice the double \r character.

When using Unix new line char (\r) only, as line delimiter, ADT is working properly. I also noticed better performance while working in "Graphical layout", and there are no extra unnecessary empty lines between xml elements.

So I guess there is bug in both ADT and Eclipse, ADT is inseting wrong line endings and Eclipse freaks out because of that.

sidon
  • 1,434
  • 1
  • 17
  • 30
1

One thing that sometimes works for me is to do Ctrl+A, Ctrl+C, Ctrl+V. Basically, select all, copy, and paste. It sounds strange, but it usually fixes the problem without having to do anything particularly time consuming.

Dave
  • 1,250
  • 1
  • 16
  • 32
1

It looks like an issue of Android or Eclipse ADT...see below links...

http://code.google.com/p/android/issues/detail?id=30529

https://bugs.eclipse.org/bugs/show_bug.cgi?id=375421

for solve this problem update your ADT to letest version.

Priyank Patel
  • 12,244
  • 8
  • 65
  • 85