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 trialalex Cash
Courses Plus Student 875 Pointswasting so much time understanding/getting this butter-knife thing to work, maybe we shouldn't even bother?
Is there an updated video showing the steps to follow?
2 Answers
jacksonpranica
17,610 PointsHey Alex,
Hard to know what the problem is. I know the troubles with ButterKnife but for the most part, there are two problems you may be running into, but Im just guessing here.
One possibility is that butterknife isnt even working for you. In that case, the problem could be that you did what I did and only put one line of code in your gradle. Unfortunately the updated version of butterknife has two lines of code for adding to Gradle.
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
Make sure you include both of these as I couldnt get anything to work until i added the annotation processor.
Second possibility is that you are having trouble with InjectView or something like that. Just make sure to use Bind in any place they use the word Inject.
As for butterknife, trust me, writing 8 (7 views and 1 butterknife.bind(this) of code) versus 14 lines of code (2 for each view) is heaven when you're working with tons of view. And then the simplicity when using an OnClick method is really a saver. I recommend dealing with this until you get butterknife working.
Joyce Chidiadi
1,867 PointsI am considering just typing out this codes no matter how long they are as this ButterKnife method is giving me a lot of trouble.
One thing, I don't know how far the ButterKnife (@BindView) has controlled other parts of the code. How can I remove all the effects of the Inject or BindView to use the normal code: Here is my new code: private TextView TemperatureLabel; private TextView TimeLabel; private TextView HumidityLabel; private TextView PrecipValue; private TextView SummaryLabel; private ImageView IconImageView; private ImageView RefreshImageView; private ProgressBar ProgressBar;
private GoogleApiClient client2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TemperatureLabel = (TextView)findViewById(R.id.temperatureLabel);
TimeLabel = (TextView)findViewById(R.id.timeLabel);
HumidityLabel = (TextView)findViewById(R.id.humidityLabel);
PrecipValue = (TextView)findViewById(R.id.precipLabel);
SummaryLabel = (TextView)findViewById(R.id.summaryLabel);
IconImageView = (ImageView)findViewById(R.id.iconImageView);
RefreshImageView = (ImageView)findViewById(R.id.refreshImageView);
ProgressBar = (ProgressBar)findViewById(R.id.progressBar);