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 Emulator Error "Unfortunately Crystal Ball has stopped"

Hi Hoping someone can assist please. The Android Emulator ran ok on the first 2 exercises. I'm now at" Introduction to Methods and Classes" but now I get the above error when I run the project , even though there are no errors showing. hoping there is a simple fix for this thanks - DT

4 Answers

Your program is probably crashing. You can see the line of code that it's crashing on if you open the LogCat window (Go to Window -> Show View -> Other, then select LogCat under Android). One of the errors probably includes the text com.example.android.CrystalBall (or something like that). If you double click on that line, it'll take you to the line of code that caused the crash. My guess is that it's crashing because you're calling a method on an object that is null.

Hi Ben, Thanks I took the above steps and found a problem on line 40, I restarted the emulator then ran the code, but the "Unfortunately Crystal Ball has stopped" message appeared on the emulator again. I'll try again tomorrow when I finish work. Appreciate your help . thanks

There's a bug in your code that needs to be fixed before it'll stop crashing. My guess is that the line that it's crashing on is where you're calling a method or accessing a property of an object that is currently null. If you post your code, I'd be glad to take a look.

Hi Ben, Thanks , here Is the code:

package com.example.crystal.ball;

import java.util.Random; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.TextView;

public abstract class MainActivity extends Activity {

public void onCreate(Bundle savedInstanceState) {

    //declare our view variables
    final TextView answerLabel = (TextView) findViewById(R.id.textView1);
    Button getAnswerButton = (Button) findViewById(R.id.button1);

    getAnswerButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            // The button was clicked so update the answer label with an answer
            String answer = " ";
            //\Randomly select one of the following answers yes, no or maybe
            Random randomGenerator = new Random(); //Construct a new random number generator
            //Update the label with our Dynamic Answer
            int randomNumber = randomGenerator.nextInt(3);
            answer = Integer.toString(randomNumber);






That code all looks good to me. Which is the line that the LogCat tells you that it's crashing on?

Hi Ben, Thanks, the LogCat is no longer showing any errors or warnings.