比如:eclipse项目是gbk编码,android studio默认各个地方用的都是utf-8。
代码中的汉字,注释中的汉字全部显示为乱码。
解决方法:在module的bulid.gradle中加入:
compileOptions.encoding = 'gbk'
像这样,gbk是eclipse项目的编码。
apply plugin: 'com.android.xxxx'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileOptions.encoding = 'gbk'
defaultConfig {
applicationId "com.xxxx.xxxx"
minSdkVersion 15
targetSdkVersion 21
}
注意,别加到project的bulid.gradle里去。
直接然后直接编译什么的就可以在as中正常用了。