Thread
#dagger
    brandonmcansh

    brandonmcansh

    1 year ago
    Hey guys posted this in #android but figured it might be better suited here:
    Hey guys hitting an issue trying to inject into a Worker with Hilt
    🧵
    E/WM-WorkerFactory: Could not instantiate am.planogr.planogram.editor.work.DownloadUseWorker
    constructor
    @HiltWorker
    class DownloadUseWorker @AssistedInject constructor(
        @Assisted appContext: Context,
        @Assisted workerParams: WorkerParameters,
        private val api: DynamicUrlHitService,
    ) : CoroutineWorker(appContext, workerParams) {
    work related deps update to 2.6.0-beta01 and hilt work is at 1.0.0
    present in manifest
    <meta-data
                    android:name="androidx.work.impl.WorkManagerInitializer"
                    android:value="androidx.startup"
                    tools:node="remove" />
    injected dependency is marked as a Singleton
    @Provides
        @Singleton
        fun providesDynamicUrlHitService(
            @Named("simple-retrofit") retrofit: Retrofit
        ): DynamicUrlHitService = retrofit.create(DynamicUrlHitService::class.java)
    Jeremy

    Jeremy

    1 year ago
    I think you need a
    return Configuration.Builder().setWorkerFactory(workerFactory).build()
    Your
    Application
    needs to implement
    Configuration.Provider
    brandonmcansh

    brandonmcansh

    1 year ago
    Forgot to add that snippet. Ended up being my metadata in the manifest that needs tweaking.