ViewBindingPropertyDelegate: Crash on button press -> java.lang.RuntimeException: View must have a tag
Hi, I’m facing an issue after upgrading to 1.4.7 while clicking a button. Downgrading to 1.4.6 fixed for me. Here’s the stack trace and code
Stacktrace
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.atees.ayurdoc.debug, PID: 25736
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at by.kirich1409.viewbindingdelegate.internal.BindViewBinding.bind(ViewBindingCache.kt:101)
at by.kirich1409.viewbindingdelegate.ReflectionFragmentViewBindings$viewBinding$3.invoke(FragmentViewBindings.kt:64)
at by.kirich1409.viewbindingdelegate.ReflectionFragmentViewBindings$viewBinding$3.invoke(FragmentViewBindings.kt:63)
at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:77)
at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:42)
at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:34)
at com.atees.ayurdoc.ui.login.LoginFragment.getBinding(LoginFragment.kt:33)
at com.atees.ayurdoc.ui.login.LoginFragment.setupClickListeners$lambda-4(LoginFragment.kt:124)
at com.atees.ayurdoc.ui.login.LoginFragment.lambda$snF-fOR_eVlj8Zahf8h-q80glhw(Unknown Source:0)
at com.atees.ayurdoc.ui.login.-$$Lambda$LoginFragment$snF-fOR_eVlj8Zahf8h-q80glhw.onClick(Unknown Source:2)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7664)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.RuntimeException: view must have a tag
at com.atees.ayurdoc.DataBinderMapperImpl.getDataBinder(DataBinderMapperImpl.java:75)
at androidx.databinding.MergedDataBinderMapper.getDataBinder(MergedDataBinderMapper.java:74)
at androidx.databinding.DataBindingUtil.bind(DataBindingUtil.java:199)
at androidx.databinding.ViewDataBinding.bind(ViewDataBinding.java:695)
at com.atees.ayurdoc.databinding.FragmentLoginBinding.bind(FragmentLoginBinding.java:136)
at com.atees.ayurdoc.databinding.FragmentLoginBinding.bind(FragmentLoginBinding.java:124)
at java.lang.reflect.Method.invoke(Native Method)
at by.kirich1409.viewbindingdelegate.internal.BindViewBinding.bind(ViewBindingCache.kt:101)
at by.kirich1409.viewbindingdelegate.ReflectionFragmentViewBindings$viewBinding$3.invoke(FragmentViewBindings.kt:64)
at by.kirich1409.viewbindingdelegate.ReflectionFragmentViewBindings$viewBinding$3.invoke(FragmentViewBindings.kt:63)
at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:77)
at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:42)
at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:34)
at com.atees.ayurdoc.ui.login.LoginFragment.getBinding(LoginFragment.kt:33)
at com.atees.ayurdoc.ui.login.LoginFragment.setupClickListeners$lambda-4(LoginFragment.kt:124)
at com.atees.ayurdoc.ui.login.LoginFragment.lambda$snF-fOR_eVlj8Zahf8h-q80glhw(Unknown Source:0)
at com.atees.ayurdoc.ui.login.-$$Lambda$LoginFragment$snF-fOR_eVlj8Zahf8h-q80glhw.onClick(Unknown Source:2)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7664)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Fragment code
@AndroidEntryPoint
class LoginFragment : Fragment(R.layout.fragment_login) {
private val binding: FragmentLoginBinding by viewBinding()
private val viewModel: LoginViewModel by viewModels()
private val args: LoginFragmentArgs by navArgs()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.lifecycleOwner = viewLifecycleOwner
binding.viewModel = viewModel
setupClickListeners()
}
private fun setupClickListeners() {
binding.btnLogin.setOnClickListener {
binding.root.showSnackBar("Pressed")
}
}
}
Extension function
fun View.showSnackBar(message: String) {
Snackbar.make(this, message, Snackbar.LENGTH_LONG).show()
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 17
same issue for my app fixed by update to 1.5.3 thx
Please, create repo with sample where the issue is reproducible
@wbervoets , I’ve just published 1.5.3 and it must be available in few hours. Please check it and write is the fix working or not