hilt-dagger

Cannot create instance of viewmodel after using Hilt in Android

南笙酒味 提交于 2020-07-07 10:32:40
问题 Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewModel() { } Here is PdfItemRepository class. @Singleton class PdfItemRepository @Inject constructor(private val pdfItemDao: PdfItemDao){ } For pdfItemDao . I created a module named DatabaseModule . Below is the code - @Module @InstallIn(ApplicationComponent::class) object DatabaseModule { @Provides fun provideDatabase(@ApplicationContext

Cannot create instance of viewmodel after using Hilt in Android

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-07 10:32:32
问题 Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewModel() { } Here is PdfItemRepository class. @Singleton class PdfItemRepository @Inject constructor(private val pdfItemDao: PdfItemDao){ } For pdfItemDao . I created a module named DatabaseModule . Below is the code - @Module @InstallIn(ApplicationComponent::class) object DatabaseModule { @Provides fun provideDatabase(@ApplicationContext