---
title: "AndroidStudio用gradle编译中文乱码"
author: "jackeysion"
date: "2015-06-12T21:51:29Z"
tags: []
categories: ["移动开发"]
slug: "androidstudio-gradle"
draft: false
lastmod: "2015-06-12T21:52:54Z"
id: 2219324
url: "https://jackeysion.iteye.com/blog/2219324"
---

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

```java

    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: )
    compile 'com.android.support:appcompat-v7:22.1.1'
}