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 an App Icon

Patrick Larkin
Patrick Larkin
1,538 Points

Unfortunately, fun facts has stopped

Hi there,

I keep trying to run my app and every time I do, my emulator displays "Unfortunately, fun facts has stopped." I looked at other questions on here and under the Devices | logcat Log level: Error I see no errors logged. Under Log level: Info there is one suspicious line stating:

04-01 01:14:19.862 906-906/plarkin.funfacts I/Choreographer๏น• Skipped 30 frames! The application may be doing too much work on its main thread.

I can tell the icon successfully uploaded, because in the menu of my emulator the icon has changed, but any time it is clicked it displays the Unfortunately error message.

Here is my funfactsactivity.java code:

package plarkin.funfacts;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Random;

import PLarkin.funfacts.ColorWheel;
import PLarkin.funfacts.FactBook;


public class funfactsactivity extends Activity {
    private FactBook mFactBook = new FactBook();
    private ColorWheel mColorWheel = new ColorWheel();

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


        final TextView factLabel = (TextView) findViewById(R.id.factTextView);
        final Button showFactButton = (Button) findViewById(R.id.showFactButton);
        final RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout);


        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String fact = mFactBook.getFact();
                factLabel.setText(fact);

                int color = mColorWheel.getColor();
                relativeLayout.setBackgroundColor(color);
                showFactButton.setTextColor(color);
            }
        };
        showFactButton.setOnClickListener(listener);
        String message = "Yay our activity was created!";
        Toast welcomeToast = Toast.makeText(this, message, Toast.LENGTH_LONG);
        welcomeToast.show();
    }
}

Any suggestions? Thank you!

2 Answers

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

One thing that seems odd to me is that it's "plarkin" in your package name, but "PLarkin" when you have your two import statements. Though, that should be indicated as an error before you're able to compile.

Try build ->clean, build ->rebuild project and then running your app again.

If that doesn't work, try narrowing down the error using the debugger (unless you haven't learned how to do that yet in the videos).

Nothing else pops out to me from the code you posted, but you could post your code to github/dropbox or something and I'll take a look.

It's not too uncommon to see the "Skipped 30 frames! The application may be doing too much work on its main thread." warning, especially if you're using an emulator. I wouldn't worry about that.

Patrick Larkin
Patrick Larkin
1,538 Points

Thank you for your response. I refactored and renamed my package name and it worked!