Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected token: Error:(40, 61) error: illegal character: \8232 in Android Studio

When I copy paste code into Android Studio sometimes (from WEB or other external source) I get some unvisible characters and I can't compile. Is there a way to avoid this? Reformat code automatically? Plugin? Change settings?

Error:(40, 61) error: illegal character: \8232

So far I delete the code any type it in by hand again.

like image 829
powder366 Avatar asked Jun 12 '15 17:06

powder366


People also ask

How do you fix an illegal character?

The “illegal character” error occurs in the compilation phase, so it's quite easy to detect. The next example shows us how it works. Ideally, to fix this problem, the only thing to do is save the file as UTF-8 without BOM encoding. After that, the problem is solved.

What is illegal character?

The JavaScript exception "illegal character" occurs when there is an invalid or unexpected token that doesn't belong at this position in the code.

Where is error code in Android Studio?

There's "Messages" tab in Android Studio. Complilation errors and warning go there. You can select it by pressing alt+0 (⌘+0 in OS X - a shortcut to View|Tool Windows|Messages).


1 Answers

I believe your file encoding is windows-1252 (bottom right corner in AS)? Here is a Blog about file encoding. I also use UTF-8 for everything. Blog about file encodings in IntelliJ

Since AS is IntelliJ-based, this also applies to AS.

like image 76
sschrass Avatar answered Oct 05 '22 03:10

sschrass