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

David Vine
David Vine
1,542 Points

Unfortunately, Crystal Ball has stopped.

When I run my app, nothing happens except I get the message: Unfortunately, Crystal Ball has stopped. In logcat, the first issue it encounters is "error opening trace file: No such file or directory (2)". Then it has some lines of blue and green text, and then orange text that says "thread exiting with uncaught exception". Then red text "FATAL EXCEPTION: main". This message continues on for many lines.

8 Answers

Hi David,

have you tried setting breakpoints in your code and use the Debugger? Perhaps that gives you more information on what is going wrong.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

First try what Bert suggested, and if you can't track down the error, post your MainActivity.java code in here as well as all the information you can get from logcat about the error.

package com.danye.crystalball;

import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;

public class MainActivity extends ActionBarActivity {

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


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

}

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.danye.crystalball.MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

</RelativeLayout>

Please help me Ben

I'm facing the same issue. Curious to see if David has resolved this problem yet!

Another facing the same issue. Did anyone find a fix for this?

I have the same issue. Please post a fix. Can't wait to continue! Thanks

I'm having the same issue. Anybody figure it out?

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Any of you experiencing this issue, please paste in all the error lines after FATAL EXCEPTION: main. That is something known as a stack trace and it helps us troubleshoot where the root of the problem is by tracing through the different code that calls it. It includes a trace through all the system methods, which can be a little overwhelming, but we just need to zero in on the lines that have to do with our own code in MainActivity.

Reza Sadri
Reza Sadri
1,506 Points

I also get the same message. Below is detail of the LogCat: : 06-01 18:44:35.648: D/AndroidRuntime(1491): Shutting down VM 06-01 18:44:35.648: W/dalvikvm(1491): threadid=1: thread exiting with uncaught exception (group=0xb1a30ba8) 06-01 18:44:35.698: E/AndroidRuntime(1491): FATAL EXCEPTION: main 06-01 18:44:35.698: E/AndroidRuntime(1491): Process: com.ra.crystalball, PID: 1491 06-01 18:44:35.698: E/AndroidRuntime(1491): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ra.crystalball/com.ra.crystalball.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.ActivityThread.access$800(ActivityThread.java:135) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.os.Handler.dispatchMessage(Handler.java:102) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.os.Looper.loop(Looper.java:136) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.ActivityThread.main(ActivityThread.java:5017) 06-01 18:44:35.698: E/AndroidRuntime(1491): at java.lang.reflect.Method.invokeNative(Native Method) 06-01 18:44:35.698: E/AndroidRuntime(1491): at java.lang.reflect.Method.invoke(Method.java:515) 06-01 18:44:35.698: E/AndroidRuntime(1491): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 06-01 18:44:35.698: E/AndroidRuntime(1491): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 06-01 18:44:35.698: E/AndroidRuntime(1491): at dalvik.system.NativeStart.main(Native Method) 06-01 18:44:35.698: E/AndroidRuntime(1491): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98) 06-01 18:44:35.698: E/AndroidRuntime(1491): at com.ra.crystalball.MainActivity.onCreate(MainActivity.java:25) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.Activity.performCreate(Activity.java:5231) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 06-01 18:44:35.698: E/AndroidRuntime(1491): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 06-01 18:44:35.698: E/AndroidRuntime(1491): ... 11 more

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Hi Reza, check the Teacher's Notes here to help with this issue! If you continue to have trouble, please post a new question in the Forum. Good luck!