Android Studio : unmappable character for encoding UTF-8

前端 未结 9 1427
无人共我
无人共我 2020-11-27 13:15

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

Error: unmappable character for encoding UTF-8
<
相关标签:
9条回答
  • 2020-11-27 13:40

    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

    0 讨论(0)
  • 2020-11-27 13:44

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

    I did it only way to fix this error.

    0 讨论(0)
  • 2020-11-27 13:48

    Adding the following to build.gradle solves the problem :

    android {
     ...
    compileOptions.encoding = 'ISO-8859-1'
     }
    
    0 讨论(0)
  • 2020-11-27 13:50

    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

    0 讨论(0)
  • 2020-11-27 13:51

    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.
    0 讨论(0)
  • 2020-11-27 13:57

    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 !

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