Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Butter Knife - Unable to bind views for Fragment

I get an exception java.lang.RuntimeException: Unable to bind views for Fragment on ButterKnife.bind(this, view). The code is as shown below:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_personal, container, false);

    ButterKnife.bind(this, view);

    BindData();

    return view;
}
like image 216
Mufaddal Gulshan Avatar asked Aug 09 '15 16:08

Mufaddal Gulshan


2 Answers

This error happens because of wrong data type of bind view

like image 161
blackHawk Avatar answered Oct 21 '22 03:10

blackHawk


Duplicate answer. Anyway my problem (and probably yours too) is:

<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    />

Then the ImageView is bound to another class, for example an ImageButton

@Bind(R.id.imageView)
ImageButton notAnImageButton
like image 36
voghDev Avatar answered Oct 21 '22 04:10

voghDev