When compiling my app, I get the following error on all of my generated WhateverFragmentOrActivityBinding classes:
error: cannot find symbol
protected WhateverFragmentOrActivityBinding(DataBindingComponent _bindingComponent, View _root,
^
symbol: class DataBindingComponent
location: class WhateverFragmentOrActivityBinding
The DataBindingComponent
class does not seem to be generated.
Having a look at the documentation for DataBindingComponent
we see:
If using Dagger 2, the developer should extend this interface and annotate the extended interface as a Component.
I am indeed using Dagger 2, so I suspect that this might be relevant. I've tried to do this myself, to no avail, and could not find it implemented on the internet. This is what I've tried:
@Component(dependencies = [AppComponent::class], modules = [(AppModule::class), (AndroidInjectionModule::class), (ActivityBuilderModule::class)])
interface BindingComponent : DataBindingComponent
However the DaggerBindingComponent class is never generated because of the cannot find symbol errors that I already had. This seems like a chicken and egg issue, so I don't feel confident that this is the solution to my issue.
The DataBindingComponent seems to be responsible for handling BindingAdapters. I have some custom binding adapters for binding an ImageView src property, but even commenting out these adapters does not help, so I'm not sure if they are related.
I tried removing Dagger from the app completely and the issue did not go away. Not sure what else to try
u_u
I was having this same issue a couple days ago, I was using product flavors and one of them (the one that I was currently working on) did not have access to a class needed, this caused ALL of binding classes to fail, I was getting multiple errors on every Activity or Fragment binding classes.
I was also using Dagger2 and one of my modules did not have access to a class (CustomBroadcastReceiver)
@Module
abstract class BroadcasReceiverModule {
@ContributesAndroidInjector
internal abstract fun contributePhoneStateBroadcastReceiver(): CustomBroadcastReceiver
}
this error was never shown after the build process, BroadcastReceiverModule was part of my "main" resources but it was not required for the flavor I was working on where CustomBroadcastReceiver did not exist
even though it was not required it still generated a bunch of errors that disapeared after I removed BroadcastReceiverModule from "main" resources and placed it only on the flavors that it was actually required
I was having the same error messages.
Then I found that Studio was showing errors when DataBinding is used/built, also build output was not showing more than 100 lines of errors by default so:
https://github.com/google/dagger/issues/306
Added this to build.gradle:
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500" // or whatever number you want
}
}
Then I found the actual error:
https://github.com/google/dagger/issues/1245
https://issuetracker.google.com/issues/115738511
Solution for me was to downgrade Dagger 2.19 to Dagger 2.16.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With