无法在设备和模拟器上运行Android项目

时间:2014-04-28 05:34:19

标签: android

04-28 10:52:09.745: E/AndroidRuntime(28536): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lociiapp/com.lociiapp.HomeActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.ActivityThread.access$600(ActivityThread.java:165)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.os.Handler.dispatchMessage(Handler.java:107)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.os.Looper.loop(Looper.java:194)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.ActivityThread.main(ActivityThread.java:5391)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at java.lang.reflect.Method.invokeNative(Native Method)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at java.lang.reflect.Method.invoke(Method.java:525)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at dalvik.system.NativeStart.main(Native Method)
04-28 10:52:09.745: E/AndroidRuntime(28536): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at com.lociiapp.HomeActivity.onCreate(HomeActivity.java:49)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.Activity.performCreate(Activity.java:5122)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1150)
04-28 10:52:09.745: E/AndroidRuntime(28536):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
04-28 10:52:09.745: E/AndroidRuntime(28536):    ... 11 more

这是我的logcat错误,我的应用程序中没有错误,即使我已经添加了appv7appcomact jar文件但是我无法在设备或模拟器上运行此项目请帮助我在哪里做错了。

1 个答案:

答案 0 :(得分:0)

如果您在ActionBarActivity中展开MainActivity,则还必须更改values-v11中的父主题。 因此值-v11中的style.xml将为 -

 <!-- res/values-v11/themes.xml -->
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
    <style name="QueryTheme" parent="@style/Theme.AppCompat">
    <!-- Any customizations for your app running on devices with Theme.Holo here -->
    </style>
 </resources>
AndroidManifest.xml中的

 <activity
        ...
        android:theme="@style/Theme.AppCompat" />