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 (retired 2014) Pretty Little Things Adding Sounds

HELPPPP PLEASEE!!!

I was working on the crystal ball project and everything was going great, and when I went to bed I had one error, when I reopened my project I had like 50+ errors. Here is my code, I have no clue what happened.

Main Activity this is the one with all the errors

package com.example.crystalball;

import com.example.crystalball.R.raw;

public class MainActivity extends ActionBarActivity {

    private CrystalBall mCrystalBall = new CrystalBall();
    private TextView mAnswerLabel;
    private Button mGetAnswerButton;
    private ImageView mCrystalBallImage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Assign the Views from the layout file
        mAnswerLabel = (TextView) findViewById(R.id.textView1);
        mGetAnswerButton= (Button) findViewById(R.id.button1);
        mCrystalBallImage.setImageResource(R.drawable.ball_animation);

        mGetAnswerButton.setOnClickListener(new View.OnClickListener() {

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

                // Update the label with out dynamic answer
                mAnswerLabel.setText(answer);

                animateCrystalBall();
                animateAnswer();
                playSound();
            }
        });
    }

    private void animateCrystalBall() {
        AnimationDrawable ballAnimation = (AnimationDrawable) mCrystalBallImage.getDrawable();
        if (ballAnimation.isRunning()) {
            ballAnimation.stop();
        }
        ballAnimation.start();
    }

    private void animateAnswer() {
        AlphaAnimation fadeinAnimation = new AlphaAnimation(0, 1);
        fadeinAnimation.setDuration(1500);
        fadeinAnimation.setFillAfter(true);

        mAnswerLabel.setAnimation(fadeinAnimation);
    }

    private void playSound() {
        MediaPlayer player = MediaPlayer.create(this, raw.crystal_ball);
        player.start();
        player.setOnCompletionListener(new OnCompletionListener() {

            public void onCompletion(MediaPlayer mp) {
                mp.release();
            }
        });
    }

    @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);
    }
}

3 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

I see the error now in your other post. Let's close this thread and consolidate over there. :) https://teamtreehouse.com/forum/adding-sounds-error-crystal-ball-has-stopped

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Your code looks fine...it sounds like something got corrupted in your project. Can you try cleaning and rebuilding it? Project > Clean

Is there any error listed that looks like it might be the root of all the others? Sometimes an error in a resource file can cause multiple errors because it ruins the generation of the R.java class that we use throughout the app.

If a clean and rebuild doesn't work, zip up your project and email it to help@teamtreehouse.com and ask our support team to forward it to me.

I tried cleaning nothing happened I read through all the errors all of them just don't make any sense most of them say "textview cant be resolved to a type" or "something got resolved to a type" It's just frustrating because this is my third time redoing the lesson because of this