1

I am following architecture-components-samples: GithubBrowserSample

I have a Viewmodel that has a dependency and is provided through constructor injection, Since App component is singleton dagger forces me to use Singleton scope only if I use any other scope for those components I get below error

com.example.AppComponent scoped with @Singleton may not reference bindings with different scopes:

I tried this as well but still same

@Binds
@IntoMap
@ViewModelKey(MyViewModel::class)
@PerActivity
abstract fun bindMyViewModel(myViewModel: MyViewModel): ViewModel
Sourabh Saldi
  • 3,567
  • 6
  • 34
  • 57
  • 2
    You would have to use the same scoped modules as your component. If you need a `PerActivity` scope, you would need another component. – Saurabh Thorat Feb 11 '20 at 07:57
  • 1
    This might also help you. [Link](https://stackoverflow.com/questions/60141954/do-we-really-need-viewmodelfactories-and-viewmodelproviders-when-using-dagger) – Muhammad Farhan Feb 11 '20 at 08:05

0 Answers0