如何配置android注释以使用utf-8编码生成java代码

时间:2016-02-05 10:05:46

标签: android encoding utf-8 annotations android-annotations

我有一个带有Android Annotations [https://github.com/excilys/androidannotations]注释的Android项目。我的Java原始文件以UTF-8编码。我遇到了错误,因为Android Annotations在构建过程中从原始版本生成的Java文件不是用UTF-8编码的。如何配置android注释以使用utf-8编码生成中间java文件?

我将Android Studio与此Gradle文件一起使用:

buildscript {
  repositories {
    mavenCentral()
    mavenLocal()
  }

  dependencies {
    // replace with the current version of the Android plugin
    classpath 'com.android.tools.build:gradle:1.5.0'
    // Since Android's Gradle plugin 0.11, you have to use android-apt >= 1.3
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  }
}

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.3.2'

dependencies {
  apt "org.androidannotations:androidannotations:$AAVersion"
  compile "org.androidannotations:androidannotations-api:$AAVersion"
  compile 'com.android.support:appcompat-v7:23.1.1'
  compile 'com.android.support:design:23.1.1'
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
  compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.9'
}

repositories {
  jcenter()
}

apt {
  arguments {
    androidManifestFile variant.outputs[0].processResources.manifestFile
    resourcePackageName android.defaultConfig.applicationId
  }
}


android {
  compileSdkVersion 23
  buildToolsVersion "23.0.2"

  defaultConfig {
    applicationId "android.pam"
    minSdkVersion 21
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_6
    targetCompatibility JavaVersion.VERSION_1_6
  }

  packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
  }

}

0 个答案:

没有答案