AndroidStudio用gradle编译中文乱码

XNYWLZC 2015-06-12

在GradleScripts下的

build.gradle(Module:app)文件中,增加一行代码:

android { compileOptions.encoding = "GBK" }

该文件全文如下:(加粗部分是关键)

applyplugin:'com.android.application'

android{

compileSdkVersion22

buildToolsVersion"22.0.1"

android{compileOptions.encoding="GBK"}

defaultConfig{

applicationId"com.jksoft.ebooks"

minSdkVersion15

targetSdkVersion22

versionCode1

versionName"1.0"

}

buildTypes{

release{

minifyEnabledfalse

proguardFilesgetDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'

}

}

}

dependencies{

compilefileTree(dir:'libs',include:['*.jar'])

compile'com.android.support:appcompat-v7:22.1.1'

}

相关推荐