Error(1,1)illegalcharacter '\ufeff' when compiling on android studio

后端 未结 15 1675
旧巷少年郎
旧巷少年郎 2020-12-14 05:50

I got an Eclipse project source code(I was told that on Android Studio, maybe they just confused), and I start to migrating the code to android studio refers to

相关标签:
15条回答
  • 2020-12-14 06:12

    Just delete the first line of the xml-file and retype it by hand (copy paste would reinsert the hidden BOM).

    0 讨论(0)
  • 2020-12-14 06:15

    The ideas in here certainly helped me but the outcome was a little different.

    I did convert my file encoding from UTF-8 to UTF-16. I was then presented with a different error. When i converted it back to UTF-8, I noted that there was a string of unrecognizable characters before my code line. I removed them and recompiled and it worked well.

    My conclusion is somehow an unrecognizable character snuck into my code. Could be programmer error, or a blind copy/paste from the web that placed a nasty hidden character. Carrying the process above as outlined by our peers here somehow allowed me to see it.

    If you'll follow this idea above, please make sure to clean/rebuild between each conversion.

    0 讨论(0)
  • 2020-12-14 06:18

    i solved this problem with this method :

    1. ctrl + A in my activity and copy all codes
    2. delete YourClass.java
    3. create YourClass.java
    4. paste all code in new java class

    This method work for me. tnx

    0 讨论(0)
  • 2020-12-14 06:18

    I try using sublime, open the file then "Save with Encoding" there choose UTF-8 (without BOM), and it works :)

    0 讨论(0)
  • 2020-12-14 06:19

    As Marcelo told, I changed file Encoding option to UTF-16. Ran it, But didn't work. Again changed to UTF-8 and Converted it. It ran successfully. If above solution doesn't work, try this.

    0 讨论(0)
  • 2020-12-14 06:20

    Simply go in notepad plus plus and open your file and in encoding option at the top bar just select utf8

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