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

Unfortunately the app has Stopped Working

Hi i am currently using android Studio 5.0.1 and i Am Working on build an interactive Story App. As i Run my app on a emulator the Error Says Unfortunately The App Has Stopped Working On The Emulator

Hello,

Could you post the logcat info for your program? This and your source code would be of great help in troubleshooting your issue.

7 Answers

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="match_parent" tools:context=".MainActivity">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/titleImageView"
    android:src="@drawable/main_title"
    android:scaleType="fitXY"
    android:contentDescription="Signals From Mars!!!"
    android:layout_below="@+id/imageView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="START YOUR ADVENTURE"
    android:id="@+id/startButton"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:ems="10"
    android:id="@+id/nameEditText"
    android:hint="Enter Your Name To Begin!"
    android:maxLength="30"
    android:layout_above="@+id/startButton"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

</RelativeLayout> This Is the xml file as i never made any changes to the mainactivity.java Thanks Aryan

This is What The LogCat says Process: app.aryan.interactivestory, PID: 1900 java.lang.RuntimeException: Unable to start activity ComponentInfo{app.aryan.interactivestory/app.aryan.interactivestory.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:152) at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:149) at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123) at app.aryan.interactivestory.MainActivity.onCreate(MainActivity.java:13) at android.app.Activity.performCreate(Activity.java:5937) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)             at android.app.ActivityThread.access$800(ActivityThread.java:144)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:135)             at android.app.ActivityThread.main(ActivityThread.java:5221)             at java.lang.reflect.Method.invoke(Native Method)             at java.lang.reflect.Method.invoke(Method.java:372)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 03-26 22:08:57.346 2015-2015/app.aryan.interactivestory D/AndroidRuntime﹕ Shutting down VM 03-26 22:08:57.346 2015-2015/app.aryan.interactivestory E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: app.aryan.interactivestory, PID: 2015 java.lang.RuntimeException: Unable to start activity ComponentInfo{app.aryan.interactivestory/app.aryan.interactivestory.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:152) at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:149) at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123) at app.aryan.interactivestory.MainActivity.onCreate(MainActivity.java:13) at android.app.Activity.performCreate(Activity.java:5937) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)             at android.app.ActivityThread.access$800(ActivityThread.java:144)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:135)             at android.app.ActivityThread.main(ActivityThread.java:5221)             at java.lang.reflect.Method.invoke(Native Method)             at java.lang.reflect.Method.invoke(Method.java:372)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Hey, sorry to hear that. Think about the changes you've made since it last stopped working. Also, have you tried a different emulator?

It looks like you changed the theme of the application to something that is not compatible with the support library. The theme info should be located in your AndroidManifest.xml file.

Hey there Aryan, was there anything that changed in the XML. It looks like the Logcat is stating something changed in the XML that it couldn't process.

how do we navigate to the logcat to see stuff like errors? my app has this problem too but idk how to check whats wrong

okay i found it, problem was requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); needed to be before super.onCreate(savedInstanceState); in Login and sign up activities

It says Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

Thanks Guys For Your help I actually checked in the Android Manifest file my line was android:theme="@style/Theme" > As it was Supposed to be this android:theme="@style/Theme.AppCompat" > Thanks For Your Help