致命异常主要;清理和构建无法修复

时间:2014-06-26 21:28:09

标签: java android

我不知道该怎么办。我尝试将主题更改为theme.appcompat,重新导入支持库,清理并重建我的项目。可以请有人告诉我为什么我的应用程序在启动时失败?我不知道为什么我改变了..我想我正在做xml的样式,但我注释掉并且没有在代码中使用。请帮忙。谢谢!

Logcat

   06-26 15:14:32.658: D/AndroidRuntime(1035): Shutting down VM
06-26 15:14:32.658: W/dalvikvm(1035): threadid=1: thread exiting with uncaught     exception (group=0xb2a61ba8)
06-26 15:14:32.678: E/AndroidRuntime(1035): FATAL EXCEPTION: main
06-26 15:14:32.678: E/AndroidRuntime(1035): Process: com.awesome.awesomest, PID: 1035
06-26 15:14:32.678: E/AndroidRuntime(1035): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.awesome.awesomest/com.awesome.awesomest.MainActivity}:     java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant)     with this activity.
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.ActivityThread.access$800(ActivityThread.java:135)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.os.Handler.dispatchMessage(Handler.java:102)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.os.Looper.loop(Looper.java:136)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.ActivityThread.main(ActivityThread.java:5017)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     java.lang.reflect.Method.invokeNative(Native Method)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     java.lang.reflect.Method.invoke(Method.java:515)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     dalvik.system.NativeStart.main(Native Method)
06-26 15:14:32.678: E/AndroidRuntime(1035): Caused by: java.lang.IllegalStateException:     You need to use a Theme.AppCompat theme (or descendant) with this activity.
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:11    1)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.j    ava:58)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     com.awesome.awesomest.MainActivity.onCreate(MainActivity.java:19)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.Activity.performCreate(Activity.java:5231)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-26 15:14:32.678: E/AndroidRuntime(1035):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-26 15:14:32.678: E/AndroidRuntime(1035):     ... 11 more
06-26 15:14:34.888: I/Process(1035): Sending signal. PID: 1035 SIG: 9
06-26 15:15:42.108: D/AndroidRuntime(1123): Shutting down VM
06-26 15:15:42.108: W/dalvikvm(1123): threadid=1: thread exiting with uncaught     exception (group=0xb2a61ba8)
06-26 15:15:42.128: E/AndroidRuntime(1123): FATAL EXCEPTION: main
06-26 15:15:42.128: E/AndroidRuntime(1123): Process: com.awesome.awesomest, PID: 1123
06-26 15:15:42.128: E/AndroidRuntime(1123): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.awesome.awesomest/com.awesome.awesomest.MainActivity}:     java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant)     with this activity.
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.ActivityThread.access$800(ActivityThread.java:135)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.os.Handler.dispatchMessage(Handler.java:102)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.os.Looper.loop(Looper.java:136)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.ActivityThread.main(ActivityThread.java:5017)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     java.lang.reflect.Method.invokeNative(Native Method)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     java.lang.reflect.Method.invoke(Method.java:515)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at         dalvik.system.NativeStart.main(Native Method)
06-26 15:15:42.128: E/AndroidRuntime(1123): Caused by: java.lang.IllegalStateException:     You need to use a Theme.AppCompat theme (or descendant) with this activity.
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:11    1)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.j    ava:58)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     com.awesome.awesomest.MainActivity.onCreate(MainActivity.java:19)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.Activity.performCreate(Activity.java:5231)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-26 15:15:42.128: E/AndroidRuntime(1123):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-26 15:15:42.128: E/AndroidRuntime(1123):     ... 11 more
06-26 15:17:04.938: I/Process(1123): Sending signal. PID: 1123 SIG: 9
06-26 15:17:30.078: D/AndroidRuntime(1170): Shutting down VM
06-26 15:17:30.078: W/dalvikvm(1170): threadid=1: thread exiting with uncaught     exception (group=0xb2a61ba8)
06-26 15:17:30.258: E/AndroidRuntime(1170): FATAL EXCEPTION: main
06-26 15:17:30.258: E/AndroidRuntime(1170): Process: com.awesome.awesomest, PID: 1170
06-26 15:17:30.258: E/AndroidRuntime(1170): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.awesome.awesomest/com.awesome.awesomest.MainActivity}:         java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant)     with this activity.
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at         android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.app.ActivityThread.access$800(ActivityThread.java:135)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.os.Handler.dispatchMessage(Handler.java:102)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.os.Looper.loop(Looper.java:136)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.app.ActivityThread.main(ActivityThread.java:5017)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     java.lang.reflect.Method.invokeNative(Native Method)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     java.lang.reflect.Method.invoke(Method.java:515)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     dalvik.system.NativeStart.main(Native Method)
06-26 15:17:30.258: E/AndroidRuntime(1170): Caused by: java.lang.IllegalStateException:     You need to use a Theme.AppCompat theme (or descendant) with this activity.
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:11    1)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.j    ava:58)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     com.awesome.awesomest.MainActivity.onCreate(MainActivity.java:19)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.app.Activity.performCreate(Activity.java:5231)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-26 15:17:30.258: E/AndroidRuntime(1170):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-26 15:17:30.258: E/AndroidRuntime(1170):     ... 11 more
06-26 15:17:34.328: I/Process(1170): Sending signal. PID: 1170 SIG: 9
06-26 16:47:36.908: D/AndroidRuntime(1266): Shutting down VM
06-26 16:47:36.908: W/dalvikvm(1266): threadid=1: thread exiting with uncaught     exception (group=0xb2a61ba8)
06-26 16:47:36.968: E/AndroidRuntime(1266): FATAL EXCEPTION: main
06-26 16:47:36.968: E/AndroidRuntime(1266): Process: com.awesome.awesomest, PID: 1266
06-26 16:47:36.968: E/AndroidRuntime(1266): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.awesome.awesomest/com.awesome.awesomest.MainActivity}:     java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant)     with this activity.
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.ActivityThread.access$800(ActivityThread.java:135)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.os.Handler.dispatchMessage(Handler.java:102)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.os.Looper.loop(Looper.java:136)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.ActivityThread.main(ActivityThread.java:5017)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     java.lang.reflect.Method.invokeNative(Native Method)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     java.lang.reflect.Method.invoke(Method.java:515)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     dalvik.system.NativeStart.main(Native Method)
06-26 16:47:36.968: E/AndroidRuntime(1266): Caused by: java.lang.IllegalStateException:     You need to use a Theme.AppCompat theme (or descendant) with this activity.
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:11    1)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.j    ava:58)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     com.awesome.awesomest.MainActivity.onCreate(MainActivity.java:19)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.Activity.performCreate(Activity.java:5231)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-26 16:47:36.968: E/AndroidRuntime(1266):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-26 16:47:36.968: E/AndroidRuntime(1266):     ... 11 more

清单
         

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.awesome.awesomerest.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

menu.xml文件

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.awesome.awesomerest.MainActivity" >

    <!-- Search, should appear as action button -->
  <item android:id="@+id/action_search"
        android:icon="@drawable/ic_action_search"
        android:title="@string/action_search"
        android:showAsAction="ifRoom" />

    <item
        android:id="@+id/action_mainmenu"
        android:orderInCategory="97"
        android:title="@string/action_mainmenu"
        app:showAsAction="never"/>

    <item
        android:id="@+id/action_help"
        android:orderInCategory="98"
        android:title="@string/action_help"
        app:showAsAction="never"/>

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="99"
        android:title="@string/action_settings"
        app:showAsAction="never"/>

</menu>

布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.awesome.awesomerest.MainActivity$PlaceholderFragment" >

 <!--    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="250dp"
        android:background="@style/AppTheme"
        android:contentDescription="@string/start_icon"
        android:src="@drawable/ic_launcher" /> -->

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="121dp"
        android:hint="@string/hello_world"
        android:text="@string/hello_world" />

</LinearLayout>

styles.xml

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Default Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
   <!-- All customizations that are NOT specific to a particular API-level can go here.         -->
    </style>


<!-- Optional Application themes. -->
<style name="LightTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/LightThemeActionBar</item>
    <item name="android:typeface">serif</item>
    <item name="android:textColor">#FF0000</item>
    <item name="android:textSize">20sp</item>
    <item name="android:paddingBottom">@dimen/activity_vertical_margin</item>
    <item name="android:paddingLeft">@dimen/activity_horizontal_margin</item>
    <item name="android:paddingRight">@dimen/activity_horizontal_margin</item>
    <item name="android:paddingTop">@dimen/activity_vertical_margin</item>
</style>
<style name="LightThemeActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:typeface">serif</item>
    <item name="android:textColor">#FF0000</item>
    <item name="android:background">@string/actionbar_background</item>
</style>


 <style name="DarkTheme" parent="Theme.AppCompat">
    <item name ="actionBarStyle">@style/DarkThemeActionBar</item> 
    <item name="android:typeface">serif</item>
    <item name="android:textColor">#FF0000</item>
    <item name="android:textSize">30sp</item>
    <item name="android:paddingBottom">@dimen/activity_vertical_margin</item>
    <item name="android:paddingLeft">@dimen/activity_horizontal_margin</item>
    <item name="android:paddingRight">@dimen/activity_horizontal_margin</item>
    <item name="android:paddingTop">@dimen/activity_vertical_margin</item>
</style>
<style name ="DarkThemeActionBar" parent="android:Widget.Holo.Light.ActionBar">
    <item name="android:typeface">serif</item>
    <item name="android:textColor">#FF0000</item>
    <item name="android:background">@string/actionbar_background</item>
</style>
</resources>

0 个答案:

没有答案