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

Having problem using Butter Knife for Building a Weather App

I'm getting a Cannot resolve symbol 'InjectView'. I copy/paste compile 'com.jakewharton:butterknife:7.0.1' into the build.gradle and then sync the gradle. copy/paste the code @InjectView(R.id.timeLabel) TextView mTimeLabel; and that's when I got the error.

4 Answers

Seth Kroger
Seth Kroger
56,412 Points

Change the line in build.gradle to: compile 'com.jakewharton:butterknife:6.1.0' Then sync project with gradle and try again.

The update to ButterKnife from 6 to 7 changed the names on most of the annotation and functions. Keeping it at version 6 should let you follow along with the course without issue.

Thanks Seth, it works perfectly. Now I can continue journey in becoming a developer

Sushant Saurabh
Sushant Saurabh
8,352 Points

There have been a couple of changes in the ButterKnife API recently. either change it in the build.gradle file to a previous version (Version 6). Or use @Bind(R.id.loginText) TextView mLoginText; and @ButterKnife.bind(this);

If you want to continue using ButterKnife 7 you can take a look at the changelog on GitHub to learn the new function names, but if you're following along with the project it's easiest to use version 6, as Seth Kroger suggested.

I'll look into it, when I'm done with this lesson. thank you.