okaymak
07/04/2018, 2:14 PMDataBindingComponent
inside a library module which is being used from an app module (in an android project):
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class <redacted>.CustomComponent, unresolved supertypes: android.databinding.DataBindingComponent
Is this a bug in kapt?okaymak
07/04/2018, 2:26 PMgildor
07/04/2018, 4:27 PMokaymak
07/04/2018, 9:22 PMbuild.gradle:
apply plugin: 'kotlin-kapt'
...
dataBinding {
enabled = true
}
This is created inside the library module:
class LifeCycleBindings(private val lifecycle: LifeCycle): LifecycleObserver {
val disposables = CompositeDisposable()
init {
lifecycle.addObserver(this)
}
@BindingAdapter("test")
fun TextView.test(test: String) {
// just for demoing
disposables.add(....)
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
fun dispose() {
disposables.dispose()
}
}
Building the project generates the following in both modules (by kapt?):
package android.databinding;
public interface DataBindingComponent {
LifeCycleBindings getLifeCycleBindings();
}
Creating the following inside the library module (and using it in the app module), gives the aforementioned error:
class LifecycleBindingComponent(private val lifecycle: Lifecycle) : DataBindingComponent {
override fun getLifeCycleBindings(): LifeCycleBindings {
return LifeCycleBindings(lifecycle)
}
}
But creating this file inside the app module (and using it in the app module) works without any problems.
I want to provide a ready made LifecycleBindingComponent
for the consumers of this library, without having to force the consumer to create a class.okaymak
07/05/2018, 7:03 AMyan
07/14/2018, 12:30 AM