GcsSloop / AndroidNote

安卓学习笔记
http://www.gcssloop.com/#blog
9.17k stars 2.14k forks source link

AS Gradle 错误: 编码 GBK 的不可映射字符 #13

Open GcsSloop opened 8 years ago

GcsSloop commented 8 years ago

产生原因:

存在中文注释,且编码为utf-8。

解决方案:

指定编译字符集为utf-8。

在所在项目之下的build.gradle中添加:

tasks.withType(JavaCompile) { options.encoding = “UTF-8” }

注:由于Gradlev2.2.1的升级,语法不向下兼容。之前解决这个问题的方法是添加:

tasks.withType(Compile) { options.encoding = “UTF-8” }

TJYOYO commented 8 years ago

学习了

zyxzhangyuxia commented 7 years ago

can not solve my problem. i tried this paraph in all build.gradle,but no effect.can you help me ?