Codegeneration error with Dagger 2.17 and Auto factory
See original GitHub issueWe use the auto factory in the project (1.0-beta5). I’m trying to update Dagger version in the project from 2.16 to 2.17 and I’m getting a build error:
java.lang.ClassCastException: com.sun.tools.javac.code.Symtab$4 cannot be cast to javax.lang.model.element.TypeElement
at com.squareup.javapoet.ClassName.get(ClassName.java:215)
at com.squareup.javapoet.TypeName$1.visitDeclared(TypeName.java:273)
at com.squareup.javapoet.TypeName$1.visitError(TypeName.java:295)
at com.squareup.javapoet.TypeName$1.visitError(TypeName.java:248)
at com.sun.tools.javac.code.Type$ErrorType.accept(Type.java:1855)
at com.squareup.javapoet.TypeName.get(TypeName.java:248)
at com.squareup.javapoet.TypeName.get(TypeName.java:243)
at com.google.auto.factory.processor.FactoryWriter.addConstructorAndProviderFields(FactoryWriter.java:103)
at com.google.auto.factory.processor.FactoryWriter.writeFactory(FactoryWriter.java:83)
at com.google.auto.factory.processor.AutoFactoryProcessor.doProcess(AutoFactoryProcessor.java:162)
at com.google.auto.factory.processor.AutoFactoryProcessor.process(AutoFactoryProcessor.java:87)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:99)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:55)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:27)
at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jetbrains.kotlin.gradle.internal.KaptExecution.run(KaptWithoutKotlincTask.kt:112)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:39)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:46)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)/
Unfortunately, the output is not clear to get exactly the location of error. I have couple of candidates but it is always hard with combination of kapt+dagger+data binding.
We use Kotlin 1.2.60 Gradle 4.9
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:12 (1 by maintainers)
Top Results From Across the Web
While using dagger 2 : e: [kapt] An exception occurred: java ...
I just suffered through this exact error. Make sure that you're returning a ViewModel from your module function (provides or binds) e.g.
Read more >Dependency injection with Dagger 2: @Inject and @Provides
Dagger 2 is a dependency injection framework developed by Google. ... First, I will describe the problem that we are going to solve...
Read more >homebrew-core - Homebrew Formulae
a2ps 4.14 Any‑to‑PostScript filter
aacgain 1.8 AAC‑supporting version of mp3gain
aalib 1.4rc5 Portable ASCII art graphics library
aamath 0.3 Renders mathematical expressions as ASCII art
Read more >Diff - platform/prebuilts/tools - Google Git
diff --git a/common/m2/repository/com/google/auto/factory/auto-factory/1.0- ... + <annotationProcessors> + <annotationProcessor>dagger.internal.codegen.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Update: you can fix this bug by explicitly depending on JavaPoet 1.11.1 in the annotation processor scope. There was a bug fixed from 1.11.0 but it looks like Dagger needs to be updated
I get kind of the same error, I’m using
dagger 2.17 android gradle 3.3.0-alpha06 kotlin 1.2.60 data binding v2 3.3.0-alpha06
I noticed that it happens when I include the processor with the kapt ‘com.google.dagger…2.17’, if I comment the line then it complains with ‘error: @dagger.android.ContributesAndroidInjector was used, but dagger.android.processor.AndroidProcessor was not found on the processor path’
Here’s the trace that I get