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 trialgenesis
1,976 PointsThis challenge seems to be broken, gives always an error
This is the error I get, even if I don't modify any code:
JavaTester.java:44: error: cannot find symbol
if (activity.mSongTitles.length < 3) {
^
symbol: variable mSongTitles
location: variable activity of type MainListActivity
1 error
4 Answers
Gloria Dwomoh
13,116 PointsTry removing activity from... "activity.mSongTitles.length" instead use "mSongTitles.length"
genesis
1,976 PointsHi.
I can't remove that as the code that have the error is the one that, I believe, checks for challenge completion. This is the initial code I get:
package com.example;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
public class MainListActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_list);
}
}
This is the error:
JavaTester.java:44: error: cannot find symbol
if (activity.mSongTitles.length < 3) {
^
symbol: variable mSongTitles
location: variable activity of type MainListActivity
1 error
Gloria Dwomoh
13,116 PointsOkay, you get that error because you are yet to do what it asks you to do which is... "Declare an array of Strings as a member variable of the MainListActivity class. Name it 'mSongTitles', make it 'public', and initialize it with at least three values." Once you do that correctly there won't be an error. If you try to submit the code without doing what it asks for it will give you an error.
genesis
1,976 PointsYes, it works when I complete this part of the challenge. But, on all others challenges if you check work before actually doing something the error looks something like this:
"Bummer! Don't forget to..."
Instead of a compiler error (that doesn't even indicate a problem with my code).
Thanks.
Gloria Dwomoh
13,116 PointsOh, yeah usually... "Don't forget to..." notes a possible error you have done. All errors don't appear in the "compiler" thing all the time.