Android Studio: unmappable字符,用于编码UTF-8

时间:2022-02-04 00:19:00

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

在将我的项目从eclipse导入android studio后,我得到了以下错误:

Error: unmappable character for encoding UTF-8

Android Studio : 0.5.8

Android工作室:0.5.8

6 个解决方案

#1


111  

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:

我遇到了同样的问题,因为有带有windows-1251编码和Cyrillic注释的文件。在基于IntelliJ IDEA的Android Studio中,你可以用两种方式来解决它:

a) convert file encoding to UTF-8 or

a)将文件编码转换为UTF-8或。

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

b)在构建中设置正确的文件编码。gradle脚本:

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.

要转换文件编码,请使用IDE右下角的菜单。选择正确的文件编码->按Reload ->选择UTF-8 ->按Convert。

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

也可以使用UTF-8来阅读这篇文章,Luke!在IntelliJ IDEA中的文件编码

#2


12  

Adding the following to build.gradle solves the problem :

添加以下内容进行构建。gradle解决了这个问题:

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

#3


6  

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

1/转换文件编码文件—>设置—>编辑器—>文件编码—>设置UTF-8

  • IDE Encoding
  • IDE编码
  • Project Encoding
  • 项目编码
  • Default encoding propertie file
  • 默认编码propertie文件

Press OK

按OK

2/ Rebuild Project

2 /重建项目

Build -> Rebuild project

构建- >重建项目

#4


4  

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

在intellij idea生成的javadoc中,我遇到了编码问题。解决办法是增加

-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

更新:更多关于在Intellij IDEA中编译Javadoc的信息,请参见我的文章

#5


0  

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.

我必须面对的一些编码问题不能通过上面的解决方案来解决。我要么更新我的Android Studio,要么在AS终端中使用下面的命令运行测试用例。

gradlew clean assembleDebug testDebug

gradlew清洁assembleDebug testDebug

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

P。你的IDE和项目的编码设置应该匹配。

Hope it helps !

希望它可以帮助!

#6


0  

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

添加系统变量(用于Windows)“JAVA_TOOL_OPTIONS”=“-Dfile.encoding = UTF8 "。

I did it only way to fix this error.

我只做了修正这个错误的方法。

#1


111  

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:

我遇到了同样的问题,因为有带有windows-1251编码和Cyrillic注释的文件。在基于IntelliJ IDEA的Android Studio中,你可以用两种方式来解决它:

a) convert file encoding to UTF-8 or

a)将文件编码转换为UTF-8或。

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

b)在构建中设置正确的文件编码。gradle脚本:

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.

要转换文件编码,请使用IDE右下角的菜单。选择正确的文件编码->按Reload ->选择UTF-8 ->按Convert。

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

也可以使用UTF-8来阅读这篇文章,Luke!在IntelliJ IDEA中的文件编码

#2


12  

Adding the following to build.gradle solves the problem :

添加以下内容进行构建。gradle解决了这个问题:

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

#3


6  

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

1/转换文件编码文件—>设置—>编辑器—>文件编码—>设置UTF-8

  • IDE Encoding
  • IDE编码
  • Project Encoding
  • 项目编码
  • Default encoding propertie file
  • 默认编码propertie文件

Press OK

按OK

2/ Rebuild Project

2 /重建项目

Build -> Rebuild project

构建- >重建项目

#4


4  

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

在intellij idea生成的javadoc中,我遇到了编码问题。解决办法是增加

-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

更新:更多关于在Intellij IDEA中编译Javadoc的信息,请参见我的文章

#5


0  

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.

我必须面对的一些编码问题不能通过上面的解决方案来解决。我要么更新我的Android Studio,要么在AS终端中使用下面的命令运行测试用例。

gradlew clean assembleDebug testDebug

gradlew清洁assembleDebug testDebug

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

P。你的IDE和项目的编码设置应该匹配。

Hope it helps !

希望它可以帮助!

#6


0  

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

添加系统变量(用于Windows)“JAVA_TOOL_OPTIONS”=“-Dfile.encoding = UTF8 "。

I did it only way to fix this error.

我只做了修正这个错误的方法。