How to get a dagger and butterfly with Gradle?

I had my project working perfectly with Butterknife to do an injection scan. But then I needed to add Dagger for dependency injection.

I have added the Gradle Annotation Processing Tool with the appropriate dagger requirement (only show the modified parts for brevity);

buildScript { repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { ... classpath 'com.jimdo.gradle:gradle-apt-plugin:0.2-SNAPSHOT' } } apply plugin: 'apt' dependencies { apt "com.squareup.dagger:dagger-compiler:${daggerVersion}" ... } 

At this point, when I create and run the application, the properties marked with the @InjectView annotation @InjectView not receive injections of the following debug messages issued by Butterknife;

 D/ButterKnife﹕ Looking up view injector for com.example.MainActivity D/ButterKnife﹕ Not found. Trying superclass com.example.FactListAbstractActivity D/ButterKnife﹕ Not found. Trying superclass android.app.Activity 
+7
android android-studio android-gradle dagger
source share
1 answer

It turns out that all I had to do was add another suitable dependency so that the annotation processing tool takes the processor included in Butterknife. This is in addition to being included as a time-dependent compilation;

 dependency { apt "com.jakewharton:butterknife:${butterknifeVersion}" compile "com.jakewharton:butterknife:${butterknifeVersion}" } 
+7
source share

All Articles