Closed SimoneBari-BS closed 1 year ago
You need to update your hilt-common, hilt-compiler, and hilt-work to 1.1.0-alpha01.
@kuanyingchou Maybe worth mentioning in the latest release notes.
Seems like Room also has to be on 2.6.0-alpha for everything to work, if using room :)
I am getting the error for the combo KSP /WorkManager annotated with @HiltWorker. However, KSP seems to be working OK with Room 2.5.2.
You need to update your hilt-common, hilt-compiler, and hilt-work to 1.1.0-alpha01.
I have the same problem as SimoneBari-BS and it is not solved by upgrading to "androidx.hilt:hilt-work:1.1.0-alpha01".
These are my dependencies relative to hilt;
//Dagger - Hilt implementation "com.google.dagger:hilt-android:2.48" ksp "com.google.dagger:hilt-compiler:2.48" implementation 'androidx.hilt:hilt-work:1.1.0-alpha01'
Best regards
Hi, @Raulsc9 , it looks like you're missing ksp "androidx.hilt:hilt-compiler:1.1.0-alpha01"
.
Thanks for your reply, but when I add that line, now I get error in the [@Insert, @Upsert, @Update, @Delete] annotations of Room, when I try to compile.
[ksp] C:/path_project.kt:27: Methods annotated with [@Insert, @Upsert, @Update, @Delete] shouldn't declare nullable parameters (com.example.models.MyFile).
It seems that the dependency "ksp "com.google.dagger:hilt-compiler:2.48", prevents nullable parameters being passed to DAO methods. Currently my hilt and room dependencies are like this;
//Room
implementation "androidx.room:room-runtime:2.6.0-rc01"
ksp "androidx.room:room-compiler:2.6.0-rc01"
implementation "androidx.room:room-ktx:2.6.0-rc01"
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.48"
ksp "com.google.dagger:hilt-compiler:2.48"
ksp "androidx.hilt:hilt-compiler:1.1.0-alpha01"
implementation 'androidx.hilt:hilt-work:1.1.0-alpha01'
I've tried removing this line;
ksp "com.google.dagger:hilt-compiler:2.48"
But then I get this error;
The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-compiler dependency was found.
Everything was working fine before I migrated to KSP. A more detailed explanation would be appreciated, best regards!
Hi, @Raulsc9 , it looks like the Room error is working as intended since 2.6.0-alpha01:
https://issuetracker.google.com/issues/68198444
Sorry about the naming but com.google.dagger:hilt-compiler
and androidx.hilt:hilt-compiler
are different things. You'll need both for hilt-work to work.
You need to update your hilt-common, hilt-compiler, and hilt-work to 1.1.0-alpha01.
hilt-compiler-1.1.0-alpha01
transitively depends on Room 2.6.0-alpha03 as you can see in the POM. Therefore you also need to migrate to Room 2.6.0 if you like to use WorkManager with Hilt + KSP.
have the same error as raulsc9's and still not solved -- using hilt versions 2.48.1 and room version of 2.6.0-alpha03 EDIT: i ended up having to fix my room models for the nullable [@insert, @upsert, https://github.com/update, @delete] -- after updating room version
I am using hilt version: 2.49, Work manager = 2.9.0. Trying to use this in multi module project facing the crash on lateinit workerFactory. Anybody has any recommendation or solution for the same?
@Sutirth hey did you find any solution ?
@AhmedKhattab01 I have downgraded the work manager to 2.7.0 and everything seems to be working fine
I'm having the same issue with WorkManager 2.9.0, downgrading to 2.8.0 fixes the problem.
When using the 2.8.0 version the overriden method on the Configuration.Provider is called getWorkManagerConfiguration. in version 2.9.0 it is an overriden variable override val workManagerConfiguration
Hi, @taleroangel , Hilt doesn't do WorkManager initialization so this is more of a WorkManager issue. Since Configuration.Provider
got rewritten in Kotlin in 2.9.0, so instead of a downgrade I think you can just update your Kotlin implementation and override the val instead.
Hello!
We recently tried to switch from KAPT to KSP using the latest release, but run into an issue preventing us from switching.
In particular, it seems that, using KSP, custom
WorkManager
s annotated with@HiltWorker
are not processed correctly and cannot be instantiated at runtime, due to the following error:This doesn't happen when using KAPT.
I have prepared a simple repo to reproduce the issue: https://github.com/SimoneBari-BS/HiltKSPWorkerManager.
Any help in fixing this issue is appreciated!