Android Studio : unmappable character for encoding UTF-8

AndroidUtf 8Android Studio

Android Problem Overview


After importing my project from eclipse into android studio i have got the following error :

Error: unmappable character for encoding UTF-8

Android Studio : 0.5.8

Android Solutions


Solution 1 - Android

I had the same problem because there was files with windows-1251 encoding and Cyrillic comments. In Android Studio which is based on IntelliJ IDEA you can solve it in two ways:

a) convert file encoding to UTF-8 or

b) set the right file encoding in your build.gradle script:

android {
    ...
    compileOptions.encoding = 'windows-1251' // write your encoding here
    ...

To convert file encoding use the menu at the bottom right corner of IDE. Select right file encoding first -> press Reload -> select UTF-8 -> press Convert.

Also read this Use the UTF-8, Luke! File Encodings in IntelliJ IDEA

Solution 2 - Android

Adding the following to build.gradle solves the problem :

android {
 ...
compileOptions.encoding = 'ISO-8859-1'
 }

Solution 3 - Android

1/ Convert the file encoding
File -> Settings -> Editor -> File encodings -> set UTF-8 for

  • IDE Encoding
  • Project Encoding
  • Default encoding propertie file

Press OK

2/ Rebuild Project

Build -> Rebuild project

Solution 4 - Android

I have the problem with encoding in javadoc generated by intellij idea. The solution is to add

-encoding UTF-8 -docencoding utf-8 -charset utf-8

into command line arguments!

UPDATE: more information about compilation Javadoc in Intellij IDEA see in my [post][1]

[1]: http://pristalovpavel.wordpress.com/2014/12/17/how-to-create-javadoc-in-intellij-idea/ "post"

Solution 5 - Android

Add system variable (for Windows) "JAVA_TOOL_OPTIONS" = "-Dfile.encoding=UTF8".

I did it only way to fix this error.

Solution 6 - Android

In Android Studio resolved it by

  1. Navigate to File > Editor > File Encodings.
  2. In global encoding set the encoding to ISO-8859-1
  3. In Project encoding set the encoding to UTF-8 and the same case to Default encoding for properties files.
  4. Rebuild project.

Solution 7 - Android

A few encoding issues that I had to face couldn't be solved by above solutions. I had to either update my Android Studio or run test cases using following command in the AS terminal.

gradlew clean assembleDebug testDebug

P.S your encoding settings for IDE and project should match.

Hope it helps !

Solution 8 - Android

If above answeres did not work, then you can try my answer because it worked for me.
Here's what worked for me.

  1. Close Android Studio
  2. Go to C:\Usersyour username
  3. Locate the Android Studio settings directory named .AndroidStudioX.X (X.X being the version)
  4. C:\Users\my_user_name.AndroidStudio4.0\system\caches
  5. Delete the caches folder and open android studio

This should fix the issue.

Solution 9 - Android

Check all 'C' characters. There are may be some cyrillic 'C's in english-looking word.
Reason for this is that in both english and russian keyboards 'C' occupies same physical button.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCoolView Question on Stackoverflow
Solution 1 - AndroidMr. BlurredView Answer on Stackoverflow
Solution 2 - AndroidPriyanka DadhichView Answer on Stackoverflow
Solution 3 - AndroidSamy ParjouView Answer on Stackoverflow
Solution 4 - AndroidanilView Answer on Stackoverflow
Solution 5 - Androidgc986View Answer on Stackoverflow
Solution 6 - Androidibrahnerd7View Answer on Stackoverflow
Solution 7 - AndroidRahulView Answer on Stackoverflow
Solution 8 - AndroidShah Nizar BalochView Answer on Stackoverflow
Solution 9 - AndroidWaldmannView Answer on Stackoverflow