public class CustomViewHolder extends RecyclerView.ViewHolder {
@Nullable @Bind(R.id.view1) public View mView1;
@Nullable @Bind(R.id.view2) public View mView2;
....
public CustomViewHolder(View view) {
super(view);
assert view != null;
ButterKnife.bind(this, view); // line 22
}
}
Not sure why I keep hitting the following error.
java.lang.RuntimeException: Unable to bind views for ....holders.CustomViewHolder
at butterknife.ButterKnife.bind(ButterKnife.java:322)
at butterknife.ButterKnife.bind(ButterKnife.java:279)
at ...holders.CustomViewHolder.<init>(CustomViewHolder.java:22)
Paste the full trace
On Wed, Dec 23, 2015, 10:03 PM Mathew Kurian [email protected]
wrote:
public class CustomViewHolder extends ViewHolder {
@Nullable @Bind(R.id.view1) public View mView1;
@Nullable @Bind(R.id.view2) public View mView2;
....
public CustomViewHolder(View view) {
super(view);assert view != null; ButterKnife.bind(this, view); // line 22}
}_Not sure why I keep hitting the following error._
java.lang.RuntimeException: Unable to bind views for ....holders.CustomViewHolder
at butterknife.ButterKnife.bind(ButterKnife.java:322)
at butterknife.ButterKnife.bind(ButterKnife.java:279)
at ...holders.CustomViewHolder.(CustomViewHolder.java:22) —
Reply to this email directly or view it on GitHub
https://github.com/JakeWharton/butterknife/issues/423.
Oops! Seems like I goofed up. Anyways, my takeaway.
Since the original Exception which caused the error is passed into a new RuntimeException (here), a better debug output can be seen when you wrap the binding with a try/catch. This will expose the "Caused by" exception (Android Studio 1.5)
try {
ButterKnife.bind(this, view);
} catch (Exception e) {
e.printStackTrace();
}
Yeah this is a problem for long traces inside of Android's code to handle printing these out. Glad you got it resolved, anyway.
Hi Jake, I wonder how we can unbind view for recycler's view holder ? I cannot find any destructor method for view holder so It can lead to memory leak issue in future!
@harry-nguyen-88 you can add a RecyclerListener to the RecyclerView, keep a reference to the binding in the ViewHolder, and then call viewHolder.unbinder.unbind() in onViewRecycled.
Most helpful comment
Oops! Seems like I goofed up. Anyways, my takeaway.
Since the original Exception which caused the error is passed into a new RuntimeException (here), a better debug output can be seen when you wrap the binding with a try/catch. This will expose the "Caused by" exception (Android Studio 1.5)