What the actual meaning `Caused by: java.lang.Runt

2020-07-06 02:25发布

Please inform me if knowing whats tag that wanted.

Caused by: java.lang.RuntimeException: view must have a tag

__BaseActivity.java

    @Override
    public void setContentView(int layoutResID) {

        mBinding.contentParent.removeAllViews();
        DataBindingUtil.inflate(LayoutInflater.from(this), layoutResID, mBinding.contentParent, true);
        super.setContentView(mBinding.getRoot());
    }

__ChildActivity.java

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.my_wallet);
}

ERROR logcat

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mydev}: java.lang.RuntimeException: view must have a tag
        at <more...>
     Caused by: java.lang.RuntimeException: view must have a tag
        at android.databinding.DataBinderMapperImpl.getDataBinder(DataBinderMapperImpl.java:121)

8条回答
手持菜刀,她持情操
2楼-- · 2020-07-06 02:56

This happened to me due to the library's layout file (the one for which the error was flagged) having the same name as another one in the app module. Both used data binding.

查看更多
家丑人穷心不美
3楼-- · 2020-07-06 02:56

Usually happens while learning about data binding in android, we usually use a main_activity.xml and then include content_main.xml but we by mistake put the <layout tag in content file. We need to put this <layout and <data tag in parent file that is used in setContentView()

查看更多
神经病院院长
4楼-- · 2020-07-06 02:56

Please convert the XML layout into data binding. this may cause this exception.like

<layout>
xml components here...
</layout>
查看更多
ゆ 、 Hurt°
5楼-- · 2020-07-06 02:57

I have used inflater without "attachToRoot". This error always occurs with issues related to inflater in adapter.

查看更多
干净又极端
6楼-- · 2020-07-06 02:59

NO idea, but working.

查看更多
爱情/是我丢掉的垃圾
7楼-- · 2020-07-06 02:59

this happened to me because one layout wasn't present for all resolution (it was only in layout and layout-normal).

查看更多
登录 后发表回答