Android WorkManager Worker Can Not Be Injected Using Dagger Hilt `@WorkerInject`


Answer :

As per the WorkManager Configuration and Initialization documentation, to use the Configuration.Provider interface on your Application, you must remove the default initializer:

<!-- In your AndroidManifest.xml --> <provider     android:name="androidx.work.impl.WorkManagerInitializer"     android:authorities="${applicationId}.workmanager-init"     tools:node="remove" /> 

Otherwise, the default initializer will still run, wiping out your custom intialization and its HiltWorkerFactory.


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools