I am working on a project where all the source files are encoded as UTF-8 so as to please the java compiler (It will spit out errors on other encodings). Everytime i save a source file with Android Studio, it will write a Byte Order Mark on the file, preventing the compilation from succeeding. How can i fix this?
As a workaround, i am manually deleting the BOM with a Hex Editor but it gets really annoying.
In Android Studio "Project" pane, right-click on the file with BOM problem(s) and select: Analyze > Inspect Code. Then click OK. You will get a list of all BOM errors in the file. You can right-click on each error and select to remove the BOM.
It seems that this is a bug in IntellJ IDEA, on which Android Studio is based.
Try this:
(Reference for above)
Another possible fix is to remove all BOMs outside Android studio (with hex editor or another text editor) and then choosing
File -> Synchronize
in AS.You can use some tool to convert your file to UTF-8 with BOM.
I used Notepad++:
<?xml version="1.0" encoding="utf-8"?>
" from file if it is. (I used Notepad for that)<?xml version="1.0" encoding="utf-8"?>
" at file start