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 an Image

Crystal Ball app crashes.

I have followed the Teachers Notes instructions but when testing the app in the emulator I get a message "Unfortunately, Crystal Ball has stopped." And in the LogCat I get this:

04-21 04:48:49.208: E/AndroidRuntime(1062): FATAL EXCEPTION: main 04-21 04:48:49.208: E/AndroidRuntime(1062): Process: com.example.crystalball, PID: 1062 04-21 04:48:49.208: E/AndroidRuntime(1062): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crystalball/com.example.crystalball.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.ActivityThread.access$800(ActivityThread.java:135) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.os.Handler.dispatchMessage(Handler.java:102) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.os.Looper.loop(Looper.java:136) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.ActivityThread.main(ActivityThread.java:5017) 04-21 04:48:49.208: E/AndroidRuntime(1062): at java.lang.reflect.Method.invokeNative(Native Method) 04-21 04:48:49.208: E/AndroidRuntime(1062): at java.lang.reflect.Method.invoke(Method.java:515) 04-21 04:48:49.208: E/AndroidRuntime(1062): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 04-21 04:48:49.208: E/AndroidRuntime(1062): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 04-21 04:48:49.208: E/AndroidRuntime(1062): at dalvik.system.NativeStart.main(Native Method) 04-21 04:48:49.208: E/AndroidRuntime(1062): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98) 04-21 04:48:49.208: E/AndroidRuntime(1062): at com.example.crystalball.MainActivity.onCreate(MainActivity.java:17) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.Activity.performCreate(Activity.java:5231) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 04-21 04:48:49.208: E/AndroidRuntime(1062): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 04-21 04:48:49.208: E/AndroidRuntime(1062): ... 11 more

2 Answers

Calvin Nix
Calvin Nix
43,828 Points

Hmm.. I would go back through and follow the teachers notes again. I actually completed this project yesterday and it took a lot of trial and error because there are a lot of places to make little mistakes.

Let me know if you are able to get it working.

I did what you said and just did it all again and it works, I must have missed something somewhere. Thank you for your help.

Calvin Nix
Calvin Nix
43,828 Points

Glad to hear you got it working! I can't tell you how long it took me to get that working also.. It was a pain!

Calvin Nix
Calvin Nix
43,828 Points

Hey Joshua,

Did you remember to change the theme in the app manifest?

Yes I did.

I am having the same issue. I have started the app from scratch following exact instructions, but the app crashes in the android emulator. This is all that has been imputed.

<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=".MainActivity" >

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

</RelativeLayout>