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

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



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

提示错误:“错误: 编码 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, 看截图

猜你喜欢

转载自blog.csdn.net/m0_37039192/article/details/79010997
今日推荐