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

后端 未结 12 899
温柔的废话
温柔的废话 2020-12-24 11:37

I received error in my xml file. \"Incorrect line ending: found carriage return (\\r) without corresponding newline (\\n).

相关标签:
12条回答
  • 2020-12-24 12:05

    It's easier than other answers:

    Ctrl + 1 -> Fix lines

    ;)

    0 讨论(0)
  • 2020-12-24 12:06

    To fix this in one of my layout XML files, I did the following from within ADT:

    • right-click on the file in the Package Explorer
    • Pick Open With -> Text Editor

    Now the offending line gets highlighted with a big red X.

    • I then deleted the line endings (combining the two lines) and then hit "return" to add it back in. In some cases I found that didn't quite work so I copied a similar line that didn't have the issue, and pasted it over top of the offending line (highlight the bad line, then paste). Sometimes it seemed that the real issue was with the line before or after it.

    Then after saving it would show up the next bad line, so lather-rinse-repeat until it's all done.

    • When all done, use right-click, Open With -> Android Common XML Editor to get back to the visual design view.

    (ADT v21.0.1, on Mac OSX Lion)

    0 讨论(0)
  • 2020-12-24 12:06

    First refresh the project then clean (Ctrl+shift+F).

    This solves the problem for me.

    0 讨论(0)
  • 2020-12-24 12:07

    Cut your whole code, save the xml, paste the code again in the file and save. It also solves at times. Though not a standard way, but works.

    0 讨论(0)
  • 2020-12-24 12:11

    Yesterday, I got this very same error message.

    My fix is by simply removing every newline after

    />
    

    So, if you have

    <Button
        />
    
    
    <Button
        />
    

    change it into

    <Button
        />
    <Button
        />
    

    Might not be the best solution.

    0 讨论(0)
  • 2020-12-24 12:14

    If you happen to get this annoying error from time to time when you open an android activity xml file just press ctrl+shift+f to reformat your text and you’re good to go!

    0 讨论(0)
提交回复
热议问题