我刚接触到android并刚刚开始在android studio 1.2.2上编写第一个hello world代码并在模拟器上运行(gennymotion)并且我正在获取 IllegalStateException 并且在模拟器中它正在显示
不幸的是你的应用已经停止了。
java.lang.RuntimeException: Unable to start activity ComponentInfo{jewellers.am.com.amjewellers/jewellers.am.com.amjewellers.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.
答案 0 :(得分:0)
由于不使用 AppCompat 主题,导致此错误:
您的申请主题必须是:
android:theme="@style/Theme.AppCompat.Light"
清单文件如下所示:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light" >
确保您在项目中添加了 AppCompat v7 库,并且您必须扩展 ActionBarActivity 。
希望这会对你有所帮助。