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 trialNikhil Vijayan
2,334 PointsI'm getting the error 'Cannot resolve method parseColor'. I've followed all the steps exactly - please help!
Here's a screenshot http://i.imgur.com/7fcmlzq.png
Everything looks exactly like it does in the tutorial, but I'm getting the error mentioned above. What gives?
(I might have updated Android Studio without realising, could that be it?)
3 Answers
Stone Preston
42,016 Pointsdont name your variables starting with capital letters. It looks like that might be causing some issues.
you have capitalized the c in your color variable:
String Color
dont capitalize it.
String color
the names of classes start with capital letters, variables start with lower case letters. make your color variable and any other references to the color variable lower case
the parseColor method is a method of the Color class, so that word needs to start with a capital c since it is a class:
int colorAsInt = Color.parseColor(color);
in the above code, Color refers to the class, whereas color refers to your color variable.
before when you had String Color, the line:
int colorAsInt = Color.parseColor(color);
was most likely treating Color as the variable Color (not the class), which does not have a method called parseColor. The Color class is what that method belongs to.
Gloria Dwomoh
13,116 PointsTry adding this import statement if you don't have it already and see if it helps.
import android.graphics.Color;
Nikhil Vijayan
2,334 PointsThanks! Stone Preston and @gloria, I made the changes you mentioned and voila!
I really need to pay atention to the capiralization, thanks so much for the quick reply. I was stuck here! 5 stars!
Gloria Dwomoh
13,116 PointsYou are welcome.