4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android プロジェクトで APT を使うためのGradle設定

Last updated at Posted at 2017-01-26

##はじめに
Butter Knifeを導入時に、Gradleの設定をしていて知ったこと。

##そもそもaptとは
aptは「Annotation Processing Tool」の略。
余談ですが、いまだにAPTって言葉使ってるの日本人だけっぽいらしいです。

aptに関して詳しくはこちらへ。

##Gradleの設定
###Gradleプラグイン2.2未満

build.gradle
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apply plugin: "com.android.application"
apply plugin: 'com.neenbedankt.android-apt'

dependencies {
    compile 'com.jakewharton:butterknife:8.5.1'
	apt 'com.jakewharton:butterknife-compiler:8.5.1'
}

上記の書き方をしている記事が多かったが、実際のところGradleプラグイン2.2以上でアノテーションプロセッサーが導入され、追加のライブラリをいれる必要がない。
Android Plugin for Gradle Release Notes

###Gradleプラグイン2.2以上

build.gradle
dependencies {
    compile 'com.jakewharton:butterknife:8.5.1'
	annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}

annotationProcessor を指定するだけでOK。

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?