butterknife
butterknife copied to clipboard
Strange behaviour of `ButterKnife.bind(this, rootView)`
Error Log - java.lang.IllegalStateException: Required view 'expanded_menu' with ID 2131362009 for method 'addGroup' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation.
onCreateView() { ButterKnife.bind(this, rootView) }
onViewCreated() { ButterKnife.bind(this, rootView); }
I have to remove this line from onCreateView()
to onViewCreated()
to remove the error mentioned above.
But after a few runs from Studio, I have to remove this line from onViewCreated()
and write it back to onCreateView()
to remove the error mentioned above.
And the loop continues, is there any permanent place where I should keep it?
Is there any chance that you have this in your dependencies section:
if (properties.containsKey('android.injected.invoked.from.ide')) {
implementation 'com.jakewharton:butterknife-reflect:10.1.0'
} else {
implementation 'com.jakewharton:butterknife:10.1.0'
kapt 'com.jakewharton:butterknife-compiler:10.1.0'
}
?
This seems like a problem with butterknife-reflect
library
Are you call Butterknife.bind() after inflate()? @miPlodder
We are facing exactly the same error on the project which is fixed by clean and rebuild but it is not a solution. And we do not have reflect library dependency in our app.
Exactly the same issue here... I build app and have crash due to this error. But after clean it works once and build again - crash...
I think it's related with change of class R by android studio, but generated adapter isn't refreshed so it has previous id which already changed.
Can you provide a test case or executable sample that demonstrates the problem?