Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,403 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.