Mufaddal Gulshan
Mufaddal Gulshan

Reputation: 1281

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;
}

Upvotes: 10

Views: 24973

Answers (3)

blackHawk
blackHawk

Reputation: 6307

This error happens because of wrong data type of bind view

Upvotes: 1

voghDev
voghDev

Reputation: 5791

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

Upvotes: 4

gropapa
gropapa

Reputation: 577

have a look on this answer Using Butter Knife in Custom BaseAdapter SubClass Results in "Unable to inject views" error

looks like you must mistake on some view type or id

Upvotes: 9

Related Questions