dagger: Compiler errors on java 11
On Android Studio 4.2, which comes bundled with java 11, the project I’m working on doesn’t build anymore.
C:\...\app\build\tmp\kapt3\stubs\...\MainApplication.java:60: error: [ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to process this class because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public class MainApplication extends com...BaseApplication implements dagger.android.HasAndroidInjector {
^C:\...\app\src\main\java\com\...\dependency_injection\ApplicationModule.java:26: error: [ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to process this class because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public class ApplicationModule {
^C:\Users\...\app\src\main\java\com\...\dependency_injection\AppComponent.java:162: error: [ComponentProcessor:MiscError] 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.
public interface AppComponent {
^
> Task :app:kaptDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
The same project builds successfully with java 8.
Are there projects where dagger 2 works with java 11 already? If so, how can I debug and see why build fails on this project?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 7
- Comments: 16 (2 by maintainers)
I simplified the repro project that was posted earlier in the thread: https://github.com/drewhannay/data-binding-dagger-jdk11-crash
I stripped out
kapt
and Kotlin entirely. I also removeddagger-android
as it was not relevant.It seems the minimum necessary to reproduce this bug is to use a data binding
@BindingAdapter
AND to run thedagger-compiler
annotation processor. If I remove dagger from the project entirely, the crash does not reproduce. Likewise, if I remove the data binding@BindingAdapter
, the crash does not reproduce. So there is some combination of the two that is producing this compiler crash.Since the upcoming AGP 7 release will require JDK 11, this seems pretty urgent to address.
Sorry for the delay, I was able to reproduce this but I still haven’t had time to debug yet – I’ll try to look into it this week.
However, from the new error message you posted in https://github.com/google/dagger/issues/2144#issuecomment-712436284, I don’t think that error is related to the
SuperficialValidation
. It seems to be something up withkapt
.For now, one workaround you can try is to create a concrete type of
DataBindingComponent
, e.g.Then you can have users inject
MyDataBindingComponent
.Hi, @bcorso I managed to debug
SuperficialValidation
but I couldnt find any relevant information. Do you have suggestion about which method or parameter to look at. With Java11 dagger cannot createDataBindingComponent
. How can I provide more detail about this?element
parameter ofvalidateElement
method before compile fail.type
parameter ofvalidateType
method before compile fail.