Search code examples
androidkotlindagger-2dagger

Getting cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method. on kotlin dagger2


error: app.sareing.core.sharedPrefs.StringPreference cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method.
public abstract void inject(@org.jetbrains.annotations.NotNull()
                     ^
  app.sareing.core.sharedPrefs.StringPreference is injected at
      app.sareing.activity.MainActivity.authToken
  app.sareing.activity.MainActivity is injected at
      app.sareing.injection.component.ActivityComponent.inject(activity)

Tried Named fields, still no luck solving this.


Solution

  • Fixed by solution here https://stackoverflow.com/a/48057282/9821453

    I was not using @fields:qualifier_name while injecting.

    Thanks