I wanted to use WorkManager with Hilt. I followed the docs and integrated the required dependencies like this into my gradle file:
// WorkManager library
implementation "androidx.work:work-runtime-ktx:$work_version"
// To use WorkManager with Hilt
implementation "androidx.hilt:hilt-work:workmanager_hilt_version"
// Annotation processor when using Kotlin
kapt "androidx.hilt:hilt-compiler:workmanager_hilt_version"
Note that the versions are work_version = "2.5.0" and workmanager_hilt_version = "1.0.0-beta01" .
Then I went to my Worker class and typed @HiltWorker as described in the documentation BUT Android Studio could not find it:
@HiltWorker
class RefreshDataWorker @AssistedInject constructor(@Assisted appContext: Context, @Assisted params: WorkerParameters): CoroutineWorker(appContext, params) { ...// some doWork() stuff }
@HiltWorker is in red letters and Android Studios can not find it. Why ? Does sth. changed in Hilt ? Is there sth. missing in the documentation ?
I hope someone can help.