question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash on button press -> java.lang.RuntimeException: View must have a tag

See original GitHub issue

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()
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:17

github_iconTop GitHub Comments

2reactions
vcimkacommented, Nov 19, 2021

same issue for my app fixed by update to 1.5.3 thx

2reactions
kirich1409commented, Jul 11, 2021

Please, create repo with sample where the issue is reproducible

Read more comments on GitHub >

github_iconTop Results From Across the Web

View must have a tag error in android data binding
When I tried to use MyViewStubBinding.bind(view / viewStub) it crash on View must have a tag. This happen because ViewStubProxy try to ...
Read more >
AutoCompleteTextView - Android Developers
android:hapticFeedbackEnabled, Boolean that controls whether a view should have haptic feedback enabled for events such as long presses.
Read more >
View must have a tag error in android data binding
I was having this problem when using an one of the array adapter, having a crash due to a click missing tag on...
Read more >
Fragement no longer exists for key android:target_state
Although using Parent Fragment avoids the crash, it's not a good solution for me because I need the request code functionality of Target...
Read more >
View binding on Android: a story of one crash | by Mike Mostovyi
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found