I have initiated a worker in my App class like below;
@HiltAndroidApp
class KutuphanemApplication:Application(),Configuration.Provider {
@Inject
lateinit var workerFactory: HiltWorkerFactory
override fun getWorkManagerConfiguration() =
Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.DEBUG)
.setWorkerFactory(workerFactory)
.build()
I want to inject a singleton dao into my worker class for update something in DB. So I am injecting dao like below;
@HiltWorker
class ClearImageNotInArchiveWorker @AssistedInject constructor(
@Assisted val appContext: Context,
@Assisted val workerParams: WorkerParameters,
private val kitapDao: KitapDao): CoroutineWorker(appContext, workerParams) {
override suspend fun doWork(): Result {...}
}
When I enquee this WorkManager class in App class , I am getting
WorkerFactory: Could not instantiate com.mesutemre.kutuphanem.job.ClearImageNotInArchiveWorker error. But application is not crashing. Is there any problem about injecting dao in here?
Also my singleton dao;
@Singleton
@Provides
fun provideKitapDao(database: KutuphanemDatabase) = database.getKitapDao();