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 trial

Android Build a Simple Android App (2014) Improving Our Code Adding More Colors

Sante Kotturi
Sante Kotturi
7,434 Points

Error in Teacher's Notes on Adding More Colors

Not sure if this is where we report issues but just thought I should let you know that the code to copy and paste in the teacher's notes containing the array of colors has an error.

It's missing the [] to initialize the array. Instead of public String mColors = {...} it should be: public String[] mColors = {...} the correct version is showed in the video but not in the notes. Just FYI Cheers, Sante

2 Answers

Harry James
Harry James
14,780 Points

Yes, I've seen this issue around the forums a few times now. It's nothing major and is pretty well explained in Android Studio but it should be fixed soon :)

Sante Kotturi
Sante Kotturi
7,434 Points

The error Android Studio produced, "Array Initializer is not allowed here", wasn't a great explanation IMO for what the problem was. It suggests the array initializer statement is ok, but the placement of the code in the class & method is wrong, which is definitely not the problem. Made me think I'd declared my member variable in the wrong place, perhaps I had messed up my curly braces and I was actually declaring it inside my method, not my class.

A more helpful error message would have been, "Array initializer missing []" but that's feedback for AStudio, not Treehouse :P

I think it would throw off someone who was just starting out pretty solidly though. It is the first android project after all.

Harry James
Harry James
14,780 Points

Hello,

I actually use Eclipse for development personally and only assumed that the message would be similar. I do see what you mean about the error message here and it may confuse some users (Especially as though this is a Beginner project).

Eclipse actually offers an extremely helpful error message and even offers a quick fix in this situation. I took a look in Android Studio and saw the same message as you and no quick fix which, is quite upsetting.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Fixed the notes! Thanks for the heads up, and sorry about that!

Sante Kotturi
Sante Kotturi
7,434 Points

No prob, thanks for the quick fix!