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
Luis Marcano
368 PointsAndroid Studio won't even load an auto-generated project
Hello guys!, hope you're alright. Problem is I'm just starting the Android Studio course but when I try to run the "Fun Facts" project for the first time (just the blank auto generated project) it doesn't even load and say "Unfortunately, Fun Facts has stopped.". I installed Genymotion since Android Studio works way too slow in computer and have tried with different versions of Android Studio but it always say something different (I haven't been able to run this simple project not even once). This is the red part in console log:
08-17 23:30:52.877 4639-4639/? E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.laptop.funfacts, PID: 4639 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.laptop.funfacts/com.example.laptop.funfacts.FunFactsActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113) at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59) at com.example.laptop.funfacts.FunFactsActivity.onCreate(FunFactsActivity.java:12) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)
2 Answers
orbyt
10,358 PointsYou should read the error.
You need to use a Theme.AppCompat theme (or descendant) with this activity.
Try going to res/values/styles and changing the theme.
Luis Marcano
368 PointsThanks! I changed
parent="android:Theme.Holo.Light.DarkActionBar">
to
parent="Theme.AppCompat.Light.DarkActionBar">
in styles.xml and it worked.
However, I'd like to know why this happens... I mean I'm just trying to run an autogenerated file and it gave me an error already, is it because it's in beta?. If it's giving me an error with something that Android Studio itself generated I don't want to think about what kind of errors I will get when I actually start coding.
orbyt
10,358 PointsI think its because your Activity is probably extending AppCompatActivity so you need to use an AppCompat theme. Are you getting an error in your IDE notifying you of that compatibility issue? If it was autogenerated like that, im not sure why.
Caleb Gustafson
205 PointsCaleb Gustafson
205 PointsTry changing the activity config from Emulator Manager. I think it tried to run activity but couldn't due to maybe linking emulator and activity by either using default or linking them your self.