question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compiler errors on java 11

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
drewhannaycommented, Mar 24, 2021

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 removed dagger-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 the dagger-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.

1reaction
bcorsocommented, Nov 23, 2020

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 with kapt.

For now, one workaround you can try is to create a concrete type of DataBindingComponent, e.g.

class MyDataBindingComponent implements DataBindingComponent {
  private final RandomBindingAdapter imagesBindingAdapter;

  @Inject
  MyDataBindingComponent(Context context) {
    this.imagesBindingAdapter = new RandomBindingAdapter(context);
  }

  @Override
  public RandomBindingAdapter getRandomBindingAdapter() {
    return imagesBindingAdapter;
  }
}

Then you can have users inject MyDataBindingComponent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Compile Java 11 Code With Source Options
I am trying to use Java 11 module as dependency on Java 1.8 project. When I try to compile Java 11 module, maven...
Read more >
Fix the top 10 most common compile time errors in Java
Top 10 common Java compile errors and how to fix them · 1. Class and source file mismatch · 2. Improper casing ·...
Read more >
JDK 11: Compilation failed due to internal java compiler error
JDK 11: Compilation failed due to internal java compiler error ... this sample can be successful compiled using Maven(JDK11) command "mvn clean compile"....
Read more >
AEM 6.5.2 compilation errors with JDK 11
This issue seems to be coming from the maven-scr-plugin. By moving to Java 11, the class files that you create will be compiled...
Read more >
[#SCXML-287] Compilation error when compiling with Java-11
When compiling with the Java-11 compiler (although source/binary version is set to 1.8), the compilation fails with: [ERROR] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found