The xml layout file and the view holder are all correct, so I still don't know why I am getting this error.
My colleagues have all double checked it already. I have created a module which holds the app module and now this error comes up.
I would appreciate any ideas or help!
Error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':apk_holder:compileBetaDebugJavaWithJavac'.
> java.lang.RuntimeException: Found data binding errors.
****/ data binding error ****msg:Could not find accessor com.laurence.ui.TitleMvvm.ViewModel.onClick and java.lang.Object has 0 abstract methods, so is not resolved as a listener
file:D:\laur\Documents\Apps\TestApp\app\src\main\res\layout\title.xml
loc:17:23 - 17:33
****\ data binding error ****
****/ data binding error ****msg:Could not find accessor com.laurence.ui.NotesMvvm.ViewModel.onClick and java.lang.Object has 0 abstract methods, so is not resolved as a listener
file:D:\laur\Documents\Apps\TestApp\app\src\main\res\layout\activity_notes.xml
loc:21:23 - 21:33
loc:61:27 - 61:37
****\ data binding error ****
****/ data binding error ****msg:Could not find accessor com.laurence.ui.SplashMvvm.ViewModel.onClick and java.lang.Object has 0 abstract methods, so is not resolved as a listener
file:D:\laur\Documents\Apps\TestApp\app\src\main\res\layout\activity_splash.xml
loc:26:31 - 26:52
****\ data binding error ****
****/ data binding error ****msg:Could not find accessor com.laurence.ui.NewMvvm.ViewModel.onClick and java.lang.Object has 0 abstract methods, so is not resolved as a listener
file:D:\laur\Documents\Apps\TestApp\app\src\main\res\layout\fragment_new.xml
loc:31:35 - 31:52
****\ data binding error ****
title.xml:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="vm"
type="com.laurence.ui.TitleMvvm.ViewModel" />
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:onClick="@{vm::onClick}">
</android.support.constraint.ConstraintLayout>
</layout>
TitleScreen.kt
interface TitleMvvm {
interface View : MvvmView
interface ViewModel : MvvmViewModel<View>{
@get:Bindable
val isClickableSection: Boolean
fun onClick()
}
}
class TitleDelegate : BaseActivity<TitleViewHolder> {
override fun createViewHolder(parent: ViewGroup): TitleViewHolder = Utils.createViewHolder(parent, R.layout.title, ::TitleViewHolder)
override fun bindViewHolder(viewHolder: TitleViewHolder, list: List<SectionItem>, position: Int) {
viewHolder.viewModel.update(list[position])
}
}
class TitleViewHolder constructor(itemView: View) : BaseViewHolder<TitleBinding, TitleMvvm.ViewModel>(itemView), TitleMvvm.View {
init {
viewHolderComponent.inject(this)
bindContentView(itemView)
}
}
@PerViewHolder
open class TitleViewModel
@Inject
constructor(private var navigator: Navigator,
private var urlHandler: UrlHandler) : BaseViewModel<TitleMvvm.View>(), TitleMvvm.ViewModel {
override fun onClick() {
if (isClickableSection) {
// yet to do something
}
}
}
Faced same problem.
So solution is Change to Project View -> Remove/Delete .Gradle
and .idea
folder -> Rebuild project -> Done
Replace app:onClick="@{vm::onClick}"
with android:onClick="@{vm::onClick}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.