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

My Crystal Ball App won't launch

It keeps saying "Unfortunately, Crystal Ball has stopped." Where do I find the error log?

Im not sure but maybe its error of the program , so you may restart your software whateer ur using , eclipse i guess and you may did a ittle error that when it runs , it works but then the error comes and it say it has stopped . As im in webdeveopement , even a little error can give me some weird resuts that i need to look for it carefuly even i it seem right like extra letter or missed semicolon . Thats what i think, i hope it helped . bdw you look realy beautiful

6 Answers

What software are you using? Android Studio or Eclipse?

In Android Studio, if you click on the Android button in the bottom left hand corner of the software, it will bring up LogCat, which is where all of the errors and other things would show up. Post your code, if you want us to help with a second pair of eyes on what exactly the error is.

Hope that helps!

Hey! I'm using Eclipse

This is from the LogCat in Eclipse:

09-11 16:52:19.000: D/AndroidRuntime(853): Shutting down VM 09-11 16:52:19.000: W/dalvikvm(853): threadid=1: thread exiting with uncaught exception (group=0xb2a90ba8) 09-11 16:52:19.140: E/AndroidRuntime(853): FATAL EXCEPTION: main 09-11 16:52:19.140: E/AndroidRuntime(853): Process: com.example.crystalball, PID: 853 09-11 16:52:19.140: E/AndroidRuntime(853): 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. 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.ActivityThread.access$800(ActivityThread.java:135) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.os.Handler.dispatchMessage(Handler.java:102) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.os.Looper.loop(Looper.java:136) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.ActivityThread.main(ActivityThread.java:5017) 09-11 16:52:19.140: E/AndroidRuntime(853): at java.lang.reflect.Method.invokeNative(Native Method) 09-11 16:52:19.140: E/AndroidRuntime(853): at java.lang.reflect.Method.invoke(Method.java:515) 09-11 16:52:19.140: E/AndroidRuntime(853): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 09-11 16:52:19.140: E/AndroidRuntime(853): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 09-11 16:52:19.140: E/AndroidRuntime(853): at dalvik.system.NativeStart.main(Native Method) 09-11 16:52:19.140: E/AndroidRuntime(853): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 09-11 16:52:19.140: E/AndroidRuntime(853): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98) 09-11 16:52:19.140: E/AndroidRuntime(853): at com.example.crystalball.MainActivity.onCreate(MainActivity.java:23) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.Activity.performCreate(Activity.java:5231) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 09-11 16:52:19.140: E/AndroidRuntime(853): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 09-11 16:52:19.140: E/AndroidRuntime(853): ... 11 more 09-11 16:57:19.627: I/Process(853): Sending signal. PID: 853 SIG: 9 09-11 16:57:20.247: D/AndroidRuntime(1120): Shutting down VM 09-11 16:57:20.247: W/dalvikvm(1120): threadid=1: thread exiting with uncaught exception (group=0xb2a90ba8) 09-11 16:57:20.257: E/AndroidRuntime(1120): FATAL EXCEPTION: main 09-11 16:57:20.257: E/AndroidRuntime(1120): Process: com.example.crystalball, PID: 1120 09-11 16:57:20.257: E/AndroidRuntime(1120): 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. 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.ActivityThread.access$800(ActivityThread.java:135) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.os.Handler.dispatchMessage(Handler.java:102) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.os.Looper.loop(Looper.java:136) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.ActivityThread.main(ActivityThread.java:5017) 09-11 16:57:20.257: E/AndroidRuntime(1120): at java.lang.reflect.Method.invokeNative(Native Method) 09-11 16:57:20.257: E/AndroidRuntime(1120): at java.lang.reflect.Method.invoke(Method.java:515) 09-11 16:57:20.257: E/AndroidRuntime(1120): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 09-11 16:57:20.257: E/AndroidRuntime(1120): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 09-11 16:57:20.257: E/AndroidRuntime(1120): at dalvik.system.NativeStart.main(Native Method) 09-11 16:57:20.257: E/AndroidRuntime(1120): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98) 09-11 16:57:20.257: E/AndroidRuntime(1120): at com.example.crystalball.MainActivity.onCreate(MainActivity.java:23) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.Activity.performCreate(Activity.java:5231) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 09-11 16:57:20.257: E/AndroidRuntime(1120): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 09-11 16:57:20.257: E/AndroidRuntime(1120): ... 11 more 09-11 17:02:20.617: I/Process(1120): Sending signal. PID: 1120 SIG: 9

Oh! I think I can help you with that error! Go into the styles.xml and make sure this is there:

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
    </style>

In your logCat it says " You need to use a Theme.AppCompat theme (or descendant) with this activity." So as long as you have a Theme.AppCompat.{somethinghere} then your application should run.

It's just because of the min and target APKs that was chosen, it's an odd little error! I have had the same thing happen on a few of my apps.

Thanks Kate!

So I went to the style.xml file and this is there:

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style><style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->

</resources>

Hmm. Not sure what the issue is then

Yeah that is odd.. What if you comment out the first style tag there and name the second (the one with AppCompat.Light, as AppTheme.

The error relates to java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

The video in treehouse uses the Theme called ** Theme.Black.NoTitleBar.Fullscreen ** . Are you using this?

If yes, then the new android update no longer supports this. However there is a work around as proposed by treehouse


1) Change your project back to using "AppTheme" like it was before in AndroidManifest.xml and the preview.

2) Add the following two lines to the file res/values/styles.xml (inside the <style name="AppTheme"> tag):

<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>

3) Set the background color to black in the file res/layout/activity_main.xml. The root element, RelativeLayout, is the one that makes up the whole screen. Add this line after the layout_height line but before the closing angle bracket >:

android:background="@android:color/black"

4) Change MainActivity to extend Activity, not ActionBarActivity


Hope this helps. Ask again if you have doubts.

Thank you Guneet! So I found most of this - but where do I change MainActivity to extend Activity. I don't see ActionBarActivity anywhere? Also, when I added in android:background="@android:color/black, I got an error on android:paddingBottom="@dimen/activity_vertical_margin" (the next one). It says:

Multiple annotations found at this line: - Attribute is missing the Android namespace prefix - Element type "RelativeLayout" must be followed by either attribute specifications, ">" or "/>".

What does this mean?