0

I'm struggling seeing why I get this error: Presenter cannot be provided without an @Provides-annotated method.

I have even tried to just strip out everything and make it as simple as possible, but I still get the error. What am I doing wrong?

Component:

@Component(modules = [SplashScreenModule::class])
interface SplashScreenComponent {
   fun presenter() : SplashScreenContract.Presenter
}

Module:

@Module
abstract class SplashScreenModule {

   @Binds
   @SplashScreenScope
   abstract fun providesSplashScreenPresenter(presenter: SplashScreenPresenter) : SplashScreenContract.Presenter
}

Presenter:

class SplashScreenPresenter : SplashScreenContract.Presenter { ... }
Aleksander Aleksic
  • 1,282
  • 3
  • 12
  • 18
  • Use a builder in the component with a BindsInstance, @BindsInstance abstract fun presenter()( presenter : StriSplashScreenContract.Presenterg ) : Builder – Vairavan Nov 28 '18 at 00:03
  • But this will require me to provide the presenter when building the component. Let's say the presenter has some dependencies, can I use BindInstance then? – Aleksander Aleksic Nov 28 '18 at 07:58
  • Dagger does not know how to either create (add `@Inject` on the constructor) or find (add a `@Provides` annotated method to a module) `SplashScreenPresenter`. You probably want constructor injection here, but you need to supply the presenter _somehow_. Please also [see the more general information here](https://stackoverflow.com/q/44912080/1837367) – David Medenjak Nov 28 '18 at 09:25

2 Answers2

0

You need the @Inject annotation,

class SplashScreenPresenter @Inject constructor() : SplashScreenContract.Presenter { ... }
Francesc
  • 25,014
  • 10
  • 66
  • 84
0

It was a silly mistake by me..

I annotated SplashScreenScope as @Qualifier instead of @Scope

Aleksander Aleksic
  • 1,282
  • 3
  • 12
  • 18