dagger: @ContributesAndroidInjector broken - nondescript error
Tried to use @ContributesAndroidInjector in a simplistic sample project but failed and no idea what the problem is. The sole build error is
dagger.internal.codegen.ComponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
interface AppComponent extends AndroidInjector<MainApplication> {
^
1 error
I followed the documentation in creating my sample code. I have no errors when I replace the @ContributesAndroidInjector with the equivalent old-style code.
Same issue with UsesGeneratedModulesApplication from the Dagger repository, at least when I build it in a Gradle project.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 26
Commits related to this issue
- Export jar versions of dagger-android and dagger-android-support, only for usage in dagger-android-processor. Maven and Gradle don't properly load sources from an .aar, and instead it is required for... — committed to google/dagger by ronshapiro 7 years ago
- Export jar versions of dagger-android and dagger-android-support, only for usage in dagger-android-processor. Maven and Gradle don't properly load sources from an .aar, and instead it is required for... — committed to google/dagger by ronshapiro 7 years ago
“Just incase anyone as dumb as me also comes across this thread”
Another dumbass in the party. You’re my life savior! I’m struggling since several hours! Who could expect that
@ContributesAndroidInjectorrequires a separate artifact! If anyone in future sees the error messagecomponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.the above could be the cause.Guys, I’m using kotlin in android studio. What was causing this error was because i was using
annotationProcessorinstead ofkaptCan you see the last line of code above? yah that one made me struggle for like 2 days. so,as i said, what was needed is kotlin application processing tool. a.k.a
kaptand notannotationProcessorThis might be dumb, but I got the same error by forgetting to include
annotationProcessor "com.google.dagger:dagger-android-processor:2.11"in my build.gradle dependencies.
Just incase anyone as dumb as me also comes across this thread as the top google result, including
android-processoras a dependency fixed the error.The error occured because I was not using
So far I was able to get away without this dependency. Would have been nice to see an error pointing in the right direction.
There is a related problem, though, when including
dagger-android-processorand usingcom.android.tools.build:gradle:2.4.0-alpha6instead of2.3.1or2.3.2:There were some changes in 2.4 to how annotation processors are handled.
Use
2.11these days, not2.11-rc2@savepopulation I just wrote
annotationProcessorto mean your annotation processor hereBe sure that you’re using
annotationProcessorfor your other annotation libraries as well. It might also beaptorkapt.Tested for 2.11 rc1 and it also builds.
Project for reference JonathanMerritt/BoneDagger
Someone reported that they get the same error on 2.3.x “when using
includeCompileClasspath”. I believe the issue is that the gradle plugin doesn’t know how to load an aar on theannotationProcessorpath