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 trialAntwain Smith
414 PointsPlugging in the Data Video
To plug in my data I had to use the newest version of Butterknife. Instead of using the @InjectView annotation, I am using the @BindView annotation, which does the same thing. I'm receiving a null pointer exception whenever I try to include the method updateDisplay. java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference Should I be converting this information to a String? If so, how? I have tried Double.toString() method, for whatever reason that didn't work and tried to force me to declare the variable as a string and then try that method, which still did not work. I'm at a total loss as to what to do next. Please help!
1 Answer
Seth Kroger
56,413 PointsLet's break down what "Attempt to invoke virtual method ... on a null object reference" You are trying to call a method (call and invoke are synonyms here). That method is setText(), which you are calling on the object to the left, a TextView. So the error message is saying that the TextView is null, not that there's any problem the data you're passing setText().
The most likely cause is a mismatch/typo in the id's you're binding between the Activity and XML for the layout, but htere can be other causes as well.