转载:http://blog.csdn.net/whu_zhangmin/article/details/46468061



今天刚学习Android Studio这个IDE来写代码,然后在代码中加了中文注释导致无法编译:

提示错误:“错误: 编码 GBK 的不可映射字符”。

错误: 编码 GBK 的不可映射字符

经过查资料发现以下方法可成功解决,故此记录。

解决方法:

在项目下的build.gradle下添加以下代码即可解决

[java] view plain copy
  1. tasks.withType(Compile) {  
  2.     options.encoding = "UTF-8"  
  3. }  

Gradle2.0+环境下需将Compile改为JavaCompile

[java] view plain copy
  1. tasks.withType(JavaCompile) {  
  2.     options.encoding = "UTF-8"  
  3. }  

而我这里就需要使用JavaComplile,看截图

错误: 编码 GBK 的不可映射字符

相关文章:

  • 2021-05-26
  • 2021-12-03
  • 2022-01-21
  • 2021-04-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-01
  • 2021-06-15
  • 2021-11-12
相关资源
相似解决方案