Skip to content Skip to sidebar Skip to footer

Android Studio Writing Bom's To Utf-8 File

I am working on a project where all the source files are encoded as UTF-8, to please the java compiler (otherwis, it will spit out errors on other encodings). Everytime I save a so

Solution 1:

Remove BOM Didn't work for me.

It's the problem for the code I copied from a website.

I wrote it again and problem solved.

Solution 2:

It seems that this is a bug in IntellJ IDEA, on which Android Studio is based.

Try this:

  1. In Settings | File Encodings Select the "Projekt"-Entry with the mouse in the second column and choose "" (Confrim removal of Encodings set in subdirectories or choose the directories where you don't wan't a default-encoding enforced.)
  2. de-select "Autodetect UTF-encoded files"
  3. select "Transparent native-to-ascii conversion"

(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.

Solution 3:

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.

Solution 4:

If you are using Android Studio 3.3.1

Just right-click on the file, from the menu you will find Remove BOM

Solution 5:

You can use some tool to convert your file to UTF-8 with BOM.

I used Notepad++:

  1. remove "<?xml version="1.0" encoding="utf-8"?>" from file if it is. (I used Notepad for that)
  2. open file with Notepad++.
  3. ensure you see characters as they should be
  4. select Menu -> Encoding -> Convert to UTF-8
  5. add "<?xml version="1.0" encoding="utf-8"?>" at file start

Post a Comment for "Android Studio Writing Bom's To Utf-8 File"