I am trying to setup Dagger 2.12 and I'm getting this error:
error: @dagger.android.ContributesAndroidInjector was used, but dagger.android.processor.AndroidProcessor was not found on the processor path
Here's how I've configured Dagger:
My Application class:
public final class App extends android.app.Application implements HasActivityInjector {
@Inject
DispatchingAndroidInjector<Activity> activityInjector;
@Override
public void onCreate() {
super.onCreate();
DaggerAppComponent.builder().build().inject(this);
}
@Override
public AndroidInjector<Activity> activityInjector() {
return activityInjector;
}
}
ActivityBindingModule:
@Module
public abstract class ActivityBindingModule {
@ContributesAndroidInjector(modules = SearchActivityModule.class)
abstract SearchActivity searchActivity();
}
SearchActivityModule:
@Module
public class SearchActivityModule {
@Provides
public SearchActivityDelegate getDelegate(SearchActivity searchActivity) {
return searchActivity;
}
@Provides
public SearchActivityPresenter providePresenter(SearchActivity searchActivity) {
return new SearchActivityPresenter(new OtherDependency(), searchActivity);
}
}
AppModule:
@Module(includes = { AndroidInjectionModule.class, ActivityBindingModule.class })
public abstract class AppModule {
}
Does anyone know what could be causing this error?
Annotation Type ContributesAndroidInjectorThe injector is implemented with a Subcomponent and will be a child of the Module 's component. This annotation must be applied to an abstract method in a Module that returns a concrete Android framework type (e.g. FooActivity , BarFragment , MyService , etc).
It's officially deprecated and you can pretty much ignore it. Google's framework, which became dominant in Android ecosystem, was originally called Dagger 2. Sometimes we still refer to it as such, but, in most cases, we simply call it Dagger today.
Class DaggerApplicationAn Application that injects its members and can be used to inject Activity s, Fragment s, Service s, BroadcastReceiver s and ContentProvider s attached to it. Injection is performed in onCreate() or the first call to AndroidInjection.
Dagger is a compile-time framework for dependency injection. It uses no reflection or runtime bytecode generation, does all its analysis at compile-time, and generates plain Java source code. Dagger is actively maintained by the same team that works on Guava.
Go to your module level build.gradle
, under
annotationProcessor 'com.google.dagger:dagger-android-processor:[YOUR VERSION NUMBER]'
,
add:
kapt 'com.google.dagger:dagger-android-processor:[YOUR VERSION NUMBER]'
.
the only solution for me was using old version of dagger (2.16)
kotlin version : 1.2.71
// dagger
implementation 'com.google.dagger:dagger-android:2.16'
implementation 'com.google.dagger:dagger-android-support:2.16'
kapt "com.google.dagger:dagger-compiler:2.16"
kapt "com.google.dagger:dagger-android-processor:2.16"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With