Butterknife: Required view "tvBalance" with ID 2131493005 for field "tvBalance" was not found. If this view is optional add "@Nullable"(fields) or "@Optional"(methods) annotation

Created on 24 Feb 2017  Â·  12Comments  Â·  Source: JakeWharton/butterknife

I hava many views id is tvBalance. for example I have a view’s id is "tvBalance" in xml A, and I have another view’s id is "tvBalance" in xml B too. and I have another view’s id is "tvBalance" in xml C too...... this error what should i do?

Most helpful comment

you are probably binding before setContentView(R.layout.your_layout_name);

All 12 comments

The error indicates that the view is not present in the view hierarchy when you are binding. You either need to mark it as nullable if the view is optional, bind at a later time when the view is present, or remove the field altogether if it's not in the layout you are binding with.

I'm sure it exists this xml,but it also exists another xml in the same id is ‘tvBalance’.

Got the same issue, have you found the solution ? I have several modules in my project. When i look inside the R2 files. I can find 2 ids with the same address value.

Got the same issue, I was trying to inflate wrong XML file. I fixed that and now it works fine.

I had also this issue, but the corresponding view was commented out in the XML file.

Got the same issue, I was trying to inflate a custom scrollview in my XML file. Changed the custom scrollview to original scrollview and I fixed that and now it works fine.

you are probably binding before setContentView(R.layout.your_layout_name);

you should add @nullable annotation , that will fix it

got issue inside the fragment, just removed the unused binded view and it works.

Oops! it wasn't set because I accidentally took out the call to setContentView()

It took me a long time to find out that the layout was wrong,setContentView()It's wrong

Build > Clean Project fixed it for me.

Was this page helpful?
0 / 5 - 0 ratings