I just started doing dependency injection using Dagger 2
. When I spun up my modules
, components
and tried to build my application, gradle
threw the error
Error:(4, 24) error: cannot find symbol class Generated
I dug into it and found that the error is in one of the classes Dagger
generates to do DI
. The particular class that's missing was javax.annotation.Generated
and the line throwing the error is the line that anntotates a Dagger
generated class as @Generated("dagger.internal.codegen.ComponentProcessor")
This question helped in finding the solution which is to add the javax
package as a dependency by adding the line compile 'org.glassfish:javax.annotation:10.0-b28'
to my gradle build file. This led to a successful build.
My question is, why is that not added as a transitive dependency for Dagger
or why hasn't anyone else faced this particular issue (I assume so, since I couldn't find any question here regarding this?