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 trialBrett Irvin
746 PointsMore deprecated ButterKnife code
The ButterKnife library seems to have been updated again, and now the code provided to cut and paste is out of date.
Instead of @Bind, use @BindView. The @InjectView is deprecated, and so is @Bind.
4 Answers
Seth Kroger
56,414 Points@benjakuben Yes, ButterKnife came out with a new major version this week. Version 8 renames the annotations again. (Dude, make up your mind already -_-) https://github.com/JakeWharton/butterknife/blob/master/CHANGELOG.md It also takes a bit more configuration to your build.gradle file to get it to work. The two lines of gradle code on the project's webpage aren't quite enough The full bit you need to add is listed in the repo's README https://github.com/JakeWharton/butterknife#download.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
Brett Irvin
746 PointsThanks, Seth. I've got it up and running now--I think the issue was that I didn't have the expanded code for the build.gradle file.
Adan Olivares
4,749 PointsThanks! I was doing it the old way too. I had just copied the one compile line and had trouble. I deleted that line and copied everything. Pasted outside the final curly brace in build.gradle
abhisheklomsh5
4,365 PointsNot able to resolve @BindView in MainActivity
I think there is some issue with the code in BindView apply plugin: 'com.android.application' apply plugin: 'com.android.library' I think we can't use both
Seth Kroger
56,414 PointsYes, your guess is correct. There are both instructions for using it with an app or a library that can be reused in other apps. You can't do both at the same time in the same module. Just go with the app instructions.
garyguermantokman
21,097 Pointsgaryguermantokman
21,097 PointsAre you adding that at the project level or module level. The compiler @ cannot seem to find the annotations. Seth Kroger
Seth Kroger
56,414 PointsSeth Kroger
56,414 PointsThe it works fine if it's all in the 'app' module. The README suggests to put the buildscript in the project level gradle file and the rest in the module. Gradle config blocks are additive, so it will work in either place.