具有基本材质设计力的Android应用程序在启动时关闭

具有基本材质设计力的Android应用程序在启动时关闭,android,material-design,android-actionbar-compat,android-toolbar,Android,Material Design,Android Actionbar Compat,Android Toolbar,我对安卓非常陌生,我正在通过一些教程学习安卓 最近,我发现了一个不错的网站,展示了标签使用的完美实现 链接是: 我在Android Studio中复制粘贴了完全相同的代码。项目ZIP附加在这里:,因为它需要大量的代码 这是一个非常简单的应用程序,没有任何主要的实现 问题是应用程序在打开时崩溃。我不知道为什么。没有理由让它崩溃,因为我已经在教程中复制粘贴了整个代码 请帮帮我 日志包括: 03-14 07:52:12.702 1814-1814/? E/AndroidRuntime﹕ FATA

我对安卓非常陌生,我正在通过一些教程学习安卓

最近,我发现了一个不错的网站,展示了标签使用的完美实现

链接是:

我在Android Studio中复制粘贴了完全相同的代码。项目ZIP附加在这里:,因为它需要大量的代码

这是一个非常简单的应用程序,没有任何主要的实现

问题是应用程序在打开时崩溃。我不知道为什么。没有理由让它崩溃,因为我已经在教程中复制粘贴了整个代码

请帮帮我

日志包括:

03-14 07:52:12.702    1814-1814/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.adhish.materialtest3, PID: 1814
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.adhish.materialtest3/com.adhish.materialtest3.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            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:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
            at android.support.v7.app.ActionBarActivityDelegateBase.setSupportActionBar(ActionBarActivityDelegateBase.java:165)
            at android.support.v7.app.ActionBarActivity.setSupportActionBar(ActionBarActivity.java:92)
            at com.adhish.materialtest3.MainActivity.onCreate(MainActivity.java:31)
            at android.app.Activity.performCreate(Activity.java:5933)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            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:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-14 07:52:12.706      499-828/? W/ActivityManager﹕ Force finishing activity com.adhish.materialtest3/.MainActivity
03-14 07:52:13.086      191-191/? E/EGL_emulation﹕ tid 191: eglCreateSyncKHR(1181): error 0x3004 (EGL_BAD_ATTRIBUTE)
03-14 07:52:13.272      499-529/? W/art﹕ Long monitor contention event with owner method=android.graphics.Bitmap com.android.server.wm.WindowManagerService.screenshotApplications(android.os.IBinder, int, int, int, boolean) from WindowManagerService.java:6033 waiters=0 for 245ms
03-14 07:52:13.281      499-555/? W/art﹕ Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12038 waiters=0 for 544ms
03-14 07:52:13.282      499-499/? W/art﹕ Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12038 waiters=1 for 540ms
03-14 07:52:13.299      499-524/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=6028, eventTime=370910, downTime=58849, deviceId=1, source=0x301 }
03-14 07:52:13.301      499-524/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=6029, eventTime=372034, downTime=58849, deviceId=1, source=0x301 }

您可以通过设置

<item name="windowActionBar">false</item> 
false
到您的styles.xml


或者您可以在样式中使用Theme.AppCompat.Light.NoActionBar而不是Theme.AppCompat.Light.darkaActionBar。xml

您可以发布日志猫吗?没有显示日志猫。应用程序在启动前崩溃。请在样式中设置为false。xml@Pooja谢谢,成功了!请告诉我问题到底是什么,这个解决方案是如何工作的?请正确阅读日志。原因:java.lang.IllegalStateException:此活动已具有由窗口装饰提供的操作栏。不要请求Window.FEATURE\u ACTION\u工具栏,并在主题中将windowActionBar设置为false以使用工具栏。