Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App (2015) Hooking Up the Model to the View Using Butter Knife for Views

J A
seal-mask
.a{fill-rule:evenodd;}techdegree
J A
Full Stack JavaScript Techdegree Student 4,646 Points

Cannot find symbol class InjectView

Like the title says, that annotation doesn't seem to want to compile. I was using the latest version of Butterknife at the time of this writing (version 8), and also tried falling back to version 6 as in the video, but that didn't work either.

Am I missing an import? I've tried clearing the build cache and rebuilding with Gradle with no success. What else can I do?

2 Answers

What about this ButterKnife.inject(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
Oziel Perez
Oziel Perez
61,321 Points

What J A is saying is that if you (or anyone) is using the latest version of ButterKnife at the time of this comment, the inject static method is know 'bind'. @InjectView is now @BindView. The function of the code remains pretty much the same.

Boban Talevski
Boban Talevski
24,793 Points

It should be

ButterKnife.bind(this);

instead of

ButterKnife.inject(this);