Dagger hilt kapt vs annotationProcessor issues
See original GitHub issueContext
My dagger-hilt
module has been coded in java
, some classes (which contains @AndroidEntryPoint
) I try to inject
were written by java
, some of them were written by kotlin. So when I use dagger hilt
to do the injection, I have some erros such as
Execution failed for task ':app:transformClassesWithAndroidEntryPointTransformForDebug'.
> javassist.NotFoundException:
BTW, I created a template project
to reproduce this bug here is the link https://github.com/underwindfall/dagger_issue_project
Some potential solutions
Try to use kapt
instead of annotationProcessor
I noticed that I was always use annotationProcessor
as implementation
dependency, at the begining of project, I thought it’s just for this "com.google.dagger:hilt-android-compiler:$hilt_version"
is only for Dagger Module
, since my dagger modules were coded by Java
only , Classes like Activity
etc we can still keep it as Kotlin
.
Turns out it’s not.
Try to use kapt
instead of annotationProcessor
did solve the issue.
Try to code only by java or by kotlin
Yes the project can be compiled.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:10
Top GitHub Comments
The example, seems fine as long as
demoModeEnabled
isn’t changed while an instance of theDashboardActivity
is active.However, if the
demoModeEnabled
value can change whileDashboardActivity
is active, it sounds like you would need to register an observer for the change and eitherDashboardActivity
manually,If you’re going with 1, you could do that by injecting
Provider<DashboardContract.Interactor>
and re-getting the value on each change.Either way, it should be possible without modifying the Dagger graph at runtime.
Gotya, thanks for clarifying. Now the details of dagger-hilt looks more clear to me.