简体   繁体   中英

Unable to run Android Project On Device and Emulator

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

This is My logcat Error and there is not Error in My Application even i have added appv7appcomact jar file But i am unable to run this Project on device or emulator Please help me where am Doing mistake .

If you are extending ActionBarActivity in your MainActivity , you will have to change the parent theme in values-v11 also. So the style.xml in values-v11 will be -

 <!-- 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>

in AndroidManifest.xml

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM