-
Notifications
You must be signed in to change notification settings - Fork 2k
DataBindingComponent could not be resolved after bumping dagger to 2.43.1 #3522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This error means that the Unfortunately, I don't think this is really something we can control/fix on the Dagger side, since we don't control what's on the classpath. My guess is that there's some race condition between javac and whatever androidx.databinding uses to generate their |
Thanks for the quick reply @bcorso . I am on the same team as @xiahl33 . We've already had issues in the past of DataBinding and Dagger causing flaky build failures 1+ years ago, and we resolved them by completely separating them (i.e. NOT having our dagger component extend Now the only connection between DataBinding and Dagger is that we have a class like public class Foo {
@Inject
public Foo() { }
public DataBindingComponent publicMethodExposingDataBindingComponent() { ... } The generated type is actually not needed by Dagger at all. Is it expected that Dagger needs to resolve every (public?) type and error out if it cannot be found? Is this a new intentional requirement of Dagger? |
Hi @cckroets, and thanks for the added context! Normally we don't validate methods unless they're annotated with dagger/java/dagger/internal/codegen/validation/InjectValidator.java Lines 369 to 377 in ea39850
However, looks like the issue is that we validate the nearest enclosing type of all annotated elements (I even left a TODO to clean this up): dagger/java/dagger/internal/codegen/processingstep/TypeCheckingProcessingStep.java Lines 75 to 78 in ea39850
For I can send out a fix this week. |
Great to hear. Thanks @bcorso ! |
…ingStep. Fixes #3522 The pre-validation should no longer be needed as `InjectValidator` validates everything itself. In addition, the pre-validation is overly broad, and validates types that are not necessary for Dagger to validate the class. RELNOTES=Fixes #3522: Avoids pre-validating the nearest enclosing type in the InjectProcessingStep. PiperOrigin-RevId: 466812816
…ingStep. Fixes #3522 The pre-validation should no longer be needed as `InjectValidator` validates everything itself. In addition, the pre-validation is overly broad, and validates types that are not necessary for Dagger to validate the class. RELNOTES=Fixes #3522: Avoids pre-validating the nearest enclosing type in the InjectProcessingStep. PiperOrigin-RevId: 466812816
Our project uses DataBinding and Dagger (no Hilt). After bumping dagger version from 2.39 to 2.43.1, we occasionally get a failure during the compileDebugJavaWithJavac task failed with this error:
error: InjectProcessingStep was unable to process 'Foo(com.xxx.MyDataBindings)' because 'androidx.databinding.DataBindingComponent' could not be resolved.
Dependency trace:
=> element (CLASS): com.xxx.Foo
=> element (METHOD): getDataBindingComponent()
=> type (EXECUTABLE method): ()androidx.databinding.DataBindingComponent
=> type (ERROR return type): androidx.databinding.DataBindingComponent
If type 'androidx.databinding.DataBindingComponent' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'androidx.databinding.DataBindingComponent' is on your classpath.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
This problem happens randomly, and can not be reproduced every time. Unfortunately we have tried a sample project but cannot seem to reproduce the issue there.
We have read the error message, and there are no other compilation errors causing this issue.
Kotlin: 1.6.21 (no kapt)
AGP: 7.2.2
Dagger: 2.43.1
Java: 11
The text was updated successfully, but these errors were encountered: