Você está na página 1de 2

Instructions for the new Dagger II

and Butter Knife dependencies


Since uploading the video, there is a new release for Butter Knife and Dagger. They have reached
the version 2.9 for Dagger and 2.5.1 for Butter Knife. One of the import changes is the way we are
adding this to our projects. Previously we where adding the apt Gradle plug in and then we would
apply it in the app Gradle file.

Some history about the apt plug in and why we were using this:

Firstly, it would allow to add at compile time only an annotation processor as a dependency and
not including it in the final APK.
The second usage was the generated code could be picked up by Android Studio.

But all of this changed with the Gradle version 2.2 in which an annotation processor was included.
So there is no reason to provide an extra one.

1) In order to update the libraries we only need to remove the class path for the apt from the
build.gradle (Project)

classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8'

2) Remove the plug in from the build.gradle(app)

apply plugin: ‘com.neenbedankt.android-apt'

3) Change the dependencies from apt to the new annotationProcessor

That’s all.

The same things goes for Butter Knife. Just switch the dependencies to the new ones.
SNIPPETS

compile 'com.google.dagger:dagger:2.9'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'

compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

Você também pode gostar