我正在尝试制作一个 Android 应用程序,当我尝试在模拟器中测试它时,会弹出错误,不幸的是,komok 已停止(komok 是我的应用程序的名称) )我已经使用 Logcat 来尝试理解这一切,但由于我不擅长 Java 开发,我似乎看不到我需要修复什么,如果有人可以看看这个并告诉我我需要做什么我做错了,我将非常感激。
这是 Logcat:
07-06 09:35:05.204 4934-4934/p110.uk.helloworld E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: p110.uk.helloworld, PID: 4934
java.lang.RuntimeException: Unable to start activity ComponentInfo{p110.uk.helloworld/p110.uk.helloworld.MyActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.access$800(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5070)
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:836)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)
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:108)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
at p110.uk.helloworld.MyActivity.onCreate(MyActivity.java:22)
at android.app.Activity.performCreate(Activity.java:5720)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1102)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.access$800(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5070)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
如果有人能告诉我问题是什么以及如何解决它,那就太好了,我认为问题是这样的:
Unable to start activity ComponentInfo{p110.uk.helloworld/p110.uk.helloworld.MyActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
但是我仍然不知道如何解决这个问题,所以如果有人知道,请帮助我,谢谢!
最佳答案
1.您的项目需要包含Android.AppCompact.v7
取决于你使用什么
Android Studio:文件 -> 项目结构 -> 依赖项 -> 按加号和 Libaray 并选择应用程序紧凑型
Eclipse - 转到构建路径 -> 库 -> 添加外部 Jar 并从 SDK 添加 AppCompat Jar
希望有帮助。
2.如果您的 Activity 扩展了 ActionBarActivity,请将其更改为 FragmentActivity
关于java - Android 应用程序在模拟器中启动时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24596494/