Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

I completely messed my code during my android development.

I was following along the CrystalBall app during this stage:http://teamtreehouse.com/library/build-a-simple-android-app/learning-the-language/simple-refactoring-2. I some how completely created a mess in my project that I tried to fix my app on the file. This was not a good I idea. TeamTreehouse is it possible for me to have the code during this video stage??? :-/ I was making allot head way.

11 Answers

Hi Gregory,

I just managed to create a quick video on troubleshooting the erros when importing files into eclipse Youtube Link

Hope this helps. Write back if this doesn't work

Thanks, I watched your solution. For some reason it didn't help(I still learned allot about the eclipse tools.), but I notice I kept receiving an error message. I don't recall what is but I remember seeing an old crystallball project in my workspace. I kept having to look in my computer and deleting old files relating to my crystalball project. Maybe that was the problem, but I after I delete all the old project files. I was able to re download the current project file and imported into eclipse with no error messages or problem. I really don't know what happen, but I was able to resolve the issue.

Thanks Gunjeet your the best!

Hi Gregory,

I'm glad it helped in some way or the other. I had some workspace issues too when I started out. Guess there was never a direct way of solving issues with eclipse :)

Good luck with your learning. See you around!

Ojong Obasi
Ojong Obasi
6,561 Points

I am not TeamTreehouse but if I understood u, at the right side menu where u watched the video from the link above, there is a link to download "Project Files".

U can go ahead and download the project files and see where you went wrong.

Ojong Obasi,

Thank you so much for the reply. I'm having issues importing that file into eclipse. I already have a file called Crystalball in my package name folder. I trying to close it and reopen the teamtreehouse file but I don't know I close my current project completely.

Objong,

I'm sorry it seems I may have closed the project correctly. I just don't know why its still showing up in my package name explorer. When I try to reopen treehouse project and import I receive this error message: Cannot import CrystalBall because the project name is in use. Both project are saved in two different file locations of my PC. Does anyone have any suggestions on how I can reopen the project?

When you say two different file locations, do you mean two different eclipse workspaces. There is a difference between the two.

What seems like a possible issue is that the namespace in ellipse is under conflict.

Try deleting the project CrystalBall, in the next screen check the tick box that says Delete contents on disk (cannot be undone)

Now create a new project and import the files. Or better import the project itself by using the import command in file and selecting general and import existing projects into workspace

Hope that helps.

Thanks everyone,

I was able to reload my project, but I have many errors in my code. I don't know why but Ben never specified which classes I should import at mark 6:40 . I'm following his every move in the video but at this particular point is where I had so many problem. In the video I was able to what code he has up before and after he made the changes. My CURRENT code is exactly on what he has but I still have many errors on my code. We was making and class and was fixing errors using the ctrl, shift and o command. This command only fixed one of the errors it did not fix all of the errors. Can anyone help me with this stage in the project?

‘’’android package com.example.crystalball;

import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

private CrystalBall mCrystalBall = new CrystalBall();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Declare our View variables and assign them the Views from the layout file
    final TextView answerLabel = (TextView) findViewById(R.id.textView1);
    Button getAnswerButton = (Button) findViewById(R.id.button1);

    getAnswerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String answer = mCrystalBall.getAnAnswer();

            // Update the label with our dynamic answer
            answerLabel.setText(answer);
        }
    });
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

} ‘’’

Can you paste the errors here?

-_- .....I tried using the meta tags, but it looks like I failed with that. If anyone could help me I would appreciated it.

They are really not errors, but more of "problems" in my console. I didn't want to import anything that I didn't know I was importing. Here you go I hope this help if not please let me know what else you need.

Description Resource Path Location Type error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. styles.xml /CrystalBall/res/values-v14 line 8 Android AAPT Problem ActionBarActivity cannot be resolved to a type MainActivity.java /CrystalBall/src/com/example/crystalball line 53 Java Problem The method findViewById(int) is undefined for the type MainActivity MainActivity.java /CrystalBall/src/com/example/crystalball line 20 Java Problem The method setContentView(int) is undefined for the type MainActivity MainActivity.java /CrystalBall/src/com/example/crystalball line 17 Java Problem error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml /CrystalBall/res/values-v11 line 7 Android AAPT Problem The method onCreate(Bundle) of type MainActivity must override or implement a supertype method MainActivity.java /CrystalBall/src/com/example/crystalball line 15 Java Problem The method onOptionsItemSelected(MenuItem) of type MainActivity must override or implement a supertype method MainActivity.java /CrystalBall/src/com/example/crystalball line 45 Java Problem error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml /CrystalBall/res/values line 7 Android AAPT Problem The method getMenuInflater() is undefined for the type MainActivity MainActivity.java /CrystalBall/src/com/example/crystalball line 40 Java Problem The method onCreateOptionsMenu(Menu) of type MainActivity must override or implement a supertype method MainActivity.java /CrystalBall/src/com/example/crystalball line 37 Java Problem The method findViewById(int) is undefined for the type MainActivity MainActivity.java /CrystalBall/src/com/example/crystalball line 21 Java Problem

Sorry, I'm having allot of formatting errors with this project.

I don't know if this would help but if you go to the link I provided in the forum and download the project you will exactly where I'm having trouble with. It the exact same code that I have.

Sure let me try that.

Hello Gunjeet,

Thank you so much! I didn't realize there was so much work to clean up the project. I wish this was covered in the tutorial it probably would of taken me weeks to figure this out. I will try your solution and bit. I will let you know if I have any problems.

Justin Ezor
Justin Ezor
2,193 Points

Hey Gregory,

I am also having tons of errors with this project at this point. What was Gunjeet's solution?

Hello Justin,

The best way to resolve this from my personal experience is deleting all the files relating to the Crystal ball project. If you have anything in the downloads folder, android project folder or any location on your computer DELETE ALL of it. LOL I know this may sounds extreme but trust me. Once you delete all the files download the project again from where you left off. Once the files have been downloaded please unzip the files in a safe location on your computer. You will then import the files into eclipse, Your errors will be gone after that. From my experience I think because I downloaded the same project twice I may have had files conflict errors. I don't know to much about this but I'm pretty sure this was the case.