LogCat错误及其含义

时间:2014-07-08 17:14:03

标签: java android eclipse listview logcat

好的,所以我做了一个关于构建我的第一个应用程序的教程,一旦我完成了我尝试在eclipse中的模拟器上运行它,我得到了一个"不幸的是你的应用程序停止了#34;信息。然后我尝试了我的实际Android设备并得到了相同的消息。我查看了我的LogCat并发现了这些错误,但在这个过程中我还不是很有能力。

这是LogCat,

07-08 12:58:53.739: E/AndroidRuntime(2015): FATAL EXCEPTION: main
07-08 12:58:53.739: E/AndroidRuntime(2015): Process: com.dummies.android.helloandroid, PID: 2015
07-08 12:58:53.739: E/AndroidRuntime(2015): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dummies.android.helloandroid/com.dummies.android.helloandroid.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.os.Handler.dispatchMessage(Handler.java:102)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.os.Looper.loop(Looper.java:136)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.ActivityThread.main(ActivityThread.java:5017)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at java.lang.reflect.Method.invokeNative(Native Method)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at java.lang.reflect.Method.invoke(Method.java:515)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at dalvik.system.NativeStart.main(Native Method)
07-08 12:58:53.739: E/AndroidRuntime(2015): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at com.dummies.android.helloandroid.MainActivity.onCreate(MainActivity.java:12)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.Activity.performCreate(Activity.java:5231)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-08 12:58:53.739: E/AndroidRuntime(2015):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
07-08 12:58:53.739: E/AndroidRuntime(2015):     ... 11 more

如果有人可以帮助解释这些意味着什么,那就很好。

谢谢

1 个答案:

答案 0 :(得分:0)

确保您已在AndroidManifest.xml中正确设置主题。

取自dev docs

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MyActivity"
            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>

您已添加应用程序兼容性库并选择其中一个主题。例如,您可以尝试使用主题: Theme.AppCompat.Light.DarkActionBar或根据您的布局和设计,将您的自定义主题用作父级。