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

I encountered an error message in one of my Android layout files (from an API library downloaded from the web) even though there was no syntax error at the indicated line number. The issue was due to a mismatch between carriage return (\r) and newline (\n) characters.



Solution:

Ways to resolve this issue for ADT Eclipse:

  1. Cut the content of the file using Command + X (macOS) / Ctrl + X (Windows).
  2. Paste the content back into the file using Command + V (macOS) / Ctrl + V (Windows).


Update (2024):

As of 2024, formatting the code using Command + Shift + F (macOS) / Ctrl + Shift + F (Windows) also resolves the issue.

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!