39

I haven't used Eclipse since 1 week ago. Today I started it and I noticed that it loaded slowly. When it was started it prompted this:

http://tinypic.com?ref=2zpk1g2&quot; target="_blank"><img src="http://i48.tinypic.com/2zpk1g2.png&quot; border="0" alt="Image and video hosting by TinyPic"></a>">

I thougth that maybe Eclipse has updated something of Android so I updated to the newest ADT. Now I have the same error but I have an extra big error that I don't know if it's because the previous error. I have tried the new feature of look how an xml layer looks in many devices. I have tried with 2 layers and now the program doesn't compiles because it says:

Incorrect line ending: found carriage return (\r) without corresponding newline (\n)

The error for one xml is in this line:

     android:layout_height="wrap_content">    

and the other one is in:

    android:orientation="horizontal">

wtf has happened? I didn't change anything nor saved it and 1 week ago all was fine.

Learning from masters
  • 2,032
  • 3
  • 29
  • 42

15 Answers15

101

I just got the same annoying problem. What I did was copying the entire code into notepad. Then from notepad, paste it back into the xml field. I know, it sounds stupid, but it worked and I have no idea why -__-"

aishareefa
  • 1,034
  • 1
  • 7
  • 2
  • 1
    My lord I thougth I was the only one with this problem. So, every time I "click" a layout do I will to copy to notepad? I just realized that this works but if I have to do this every time... It's going to be as the annoying error of restart eclipse and kill adb every time you start an emulator. "Patience with google" should be in bold with 90 points in every book of android – Learning from masters Nov 15 '12 at 19:02
  • I was so incredulous of this solution until I tried it and it fixed the problem! Eclipse really needs to get it together... – wasabi Nov 16 '12 at 17:22
  • 12
    For me it sufficies to just copy&paste the code (without the intermediate notepad step) – Hyndrix Nov 28 '12 at 06:21
  • CTRL-C followed by CTRL-V just as @Hyndrix said – Allen Edwards Dec 01 '12 at 23:33
  • Using Ctrl + shift + f does the same thing but faster. Look below. – AndroidPenguin Dec 11 '12 at 01:43
  • This didn't work for me ... only the lint fix did. I think the formatter itself is crewing this up. – Dheeraj Bhaskar Dec 26 '12 at 19:36
51

Simple solution:

Press: Ctrl + Shift + F and then save. It's a matter of formatting. This will format it.

AndroidPenguin
  • 3,445
  • 2
  • 21
  • 42
23

As Tor says here, this is because they have solved the problem of "transparent" lines in xml, that weird error that when you click one line you were in another.

As also he says, if you have this error is because you had files that can cause this "transparent" error so:

Simply open up the file and invoke Ctrl-1; that will show the available quickfixes, and there's a quickfix for this line warning which will go and clean up the line endings in the given file.

(Click over the error, press ctrl+1, you will see the fix)

Learning from masters
  • 2,032
  • 3
  • 29
  • 42
7

This is a very funny problem that I am also facing. The solution is simple. Just try out following on same page.

Ctrl+A, Ctrl+X, then Ctrl+V

Happy coding.

doubleDown
  • 8,048
  • 1
  • 32
  • 48
Umesh
  • 1,609
  • 1
  • 17
  • 28
6

Go to Preference -> Android -> Lint Error checking, then search for ID = MangledCRLF, change its severity below "error". This will fix the problem for the error - "Incorrect line ending: found carriage return (\r) without corresponding newline (\n)"

Khobaib
  • 1,577
  • 3
  • 21
  • 29
4

Try cleaning the project:

Project -> Clean... -> Clean All

It worked for me. Hope it helps.

Tim Kist
  • 1,164
  • 1
  • 14
  • 38
1

The best way to do it is to use lint through Android layout editor, and use the "fix" button.

Aerilys
  • 1,628
  • 1
  • 16
  • 22
0

My solution to the Android SDK/ADT 21 xml layout error.

Incorrect line ending: found carriage return (\r) without corresponding newline (\n)

Example:

<TextView
    android:id="@+id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
/>

/>from here...

Marking the space between the tags after where you get the error and hit enter and then ctrl s (save) removes it.

...to here<

<TextView
    android:id="@+id/text2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
/>

update: if it's only one line between the tags, set the marker there and press ctrl+d (delete) and the ctrl+s (save)

TouchBoarder
  • 6,422
  • 2
  • 52
  • 60
0

Just Go to --> window option and than click clear option and ok.

Incorrect line ending: found carriage return (\r) without corresponding newline (\n).

Abdul Rahman
  • 2,097
  • 4
  • 28
  • 36
0

One more possible solution is, to format the layout xml file which lead to this error. If you are using eclipse then use short cut Ctrl+i and save the file. With this you should be able to get rid off this error for that particular file permanently

Jeevan
  • 8,532
  • 14
  • 49
  • 67
0

It is because you have commented few portions of the code. Remove that code and save. This thing worked for me.

Sudheesh VS
  • 257
  • 3
  • 4
0

This is one of the best solution to change your Lint settings for permanent fix Click here

OR
Do this

Go to windows-> Preference -> Android -> Lint Error checking, then search for ID = MangledCRLF, change its severity below "error" to "warning". It will fix your problem

Community
  • 1
  • 1
Atul Bhardwaj
  • 6,647
  • 5
  • 45
  • 63
0

just cut and paste. It will work.

W00di
  • 954
  • 12
  • 21
0

Here is the solution what I came across

Solution 1: - Open layout file Ctrl+Shift+F (Command+Shift+F in MacOSX) Save the layout file and close it. Delete any .out files the builder might have created. Clean project.

Solution 2: - Also you can select the complete code, cut it and then paste it again. This will not disturb your xml formatting as well.

Solution 3: For few of the coders it works just after cleaning the project

Hope this will help. Please do let me know if I can be of any help

Summved Jain
  • 872
  • 2
  • 18
  • 21
-1

Maybe you need to put /> at the end,

Try this:

android:layout_height="wrap_content"/>   
Jay
  • 69
  • 3