无法在 android studio 3.1.4 中加载 AppCompat ActionBar 并出现未知错误 [英] Failed to load AppCompat ActionBar with unknown error in android studio 3.1.4

查看:28
本文介绍了无法在 android studio 3.1.4 中加载 AppCompat ActionBar 并出现未知错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 android studio 中收到此错误

I am getting this error in android studio

渲染问题

Failed to load AppCompat ActionBar with unknown error.

无法实例化一个或多个类

Failed to instantiate one or more classes

    The following classes could not be instantiated:
- android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)
- android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard 

所以我找到了两个解决方案,但有什么区别?我不想降级并可能遇到未来的问题,我不知道其他解决方案 (2) 的作用.

So I found two solutions but, what's the difference? I don't want to downgrade and possibly run into future problems and I don't know what the other solution(2) does.

解决方案 1 - 降级

Solution 1 - Downgrade

渲染错误android工作室无法加载 appcompat 操作栏,即使在匹配库版本之后也是如此

解决方案 2 - 不确定它的作用

Solution 2 - Not sure what it does

无法加载 AppCompat ActionBar,出现未知错误?

P.S 安卓工作室新手

P.S New to android studio

推荐答案

正如多娜所说.但无需更改等级,只需更改样式 xml 文件:

As Dona said. But no need to change the gradel, Just change the styles xml-file from: