androidgradledagger-2dagger-hiltandroid-workmanager

@HiltAndroidApp is unresolved after adding hilt-work dependency


I have working app. I use Hilt for di. But when I tried to add HiltWorker - I get strange error with @HiltAndroidApp annotation, suddenly this annotation turns red and stops resolving.

This will happen exactly after adding this dependency:

implementation(libs.workmanager.hilt)

//in libs
workmanager-hilt = { module = "androidx.hilt:hilt-work", version = "1.1.0" }

I think that this happened because of conflict with other hilt dependencies, but no idea how to understand with with and how to fix it

Here is my other dependencies:

// Hilt
implementation("com.google.dagger:hilt-android:2.44")
implementation("com.google.dagger:dagger:2.44")
kapt("com.google.dagger:hilt-compiler:2.44")
kapt("com.google.dagger:hilt-android-compiler:2.44")
kapt("com.google.dagger:dagger-compiler:2.44")

// WorkManager
implementation("androidx.work:work-runtime:2.8.1")
implementation("androidx.work:work-runtime-ktx:2.8.1")
implementation("androidx.hilt:hilt-work:1.1.0")

androidTestImplementation("com.google.dagger:hilt-android-testing:2.44")
androidTestImplementation("com.google.dagger:hilt-android:2.44")

Solution

  • So. It's strange but I solve this issue by downgrading androidx.hilt:hilt-work version to 1.0.0 I did not find information about the incompatibility of these versions of androidx.hilt and com.google.dagger, but at the moment I was able to fix the problem this way. If anyone has any additional information on this, I'd be glad to read it