dagger - No injectable members on android.app.Application. Do you want to add an injectable constructor? required by provideOkHttpClient -


i trying merge u2020 , dagger's example android-activity-graphs in following repo.

however, getting compile time error:

error:(32, 8) error: no injectable members on android.app.application. want add injectable constructor? required provideokhttpclient(android.app.application) org.kamol.nefete.activitymodule 

you haven't bound application, have bound context, somewhere else in graph, have type depends on application. downstream dependencies need application attempt implicitly bind because dagger cannot know object requires application can satisfied @forapplication context. since application not have @inject constructor nor @inject fields, dagger fail.

you can fix example adding

@provides @singleton application provideapplicationcontext() {   return application; } 

in org.kamol.nefete.androidmodule

as aside, recommend against binding context abstract supertype , easy confuse activity contexts, if binding @qualifier annotation, such @forapplication context. recommend instead binding application , having things depend on more concrete type.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -