AndroidStudio用gradle编译中文乱码

在Gradle Scripts下的
build.gradle(Module:app)文件中,增加一行代码:

    android { compileOptions.encoding = "GBK" }



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

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    android { compileOptions.encoding = "GBK" }

    defaultConfig {
        applicationId "com.jksoft.ebooks"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
}

猜你喜欢

转载自jackeysion.iteye.com/blog/2219324
今日推荐