Strange xml error: Incorrect line ending

佐手、 提交于 2019-12-02 18:46:43

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 -__-"

Simple solution:

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

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)

Umesh

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.

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)"

Try cleaning the project:

Project -> Clean... -> Clean All

It worked for me. Hope it helps.

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

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)

Mohsin raza

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

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

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

Atul Bhardwaj

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

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

just cut and paste. It will work.

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

Maybe you need to put /> at the end,

Try this:

android:layout_height="wrap_content"/>   
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!