android - 无法在 android studio 3.1.4 中加载 AppCompat ActionBar 并出现未知错误

标签 android android-studio gradle android-gradle-plugin

我在 android studio 中遇到这个错误

渲染问题

Failed to load AppCompat ActionBar with unknown error.

无法实例化一个或多个类

    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 

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

解决方案 1 - 降级

Render error android studio failed to load appcompat action bar, even after matching library versions

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

Failed to load AppCompat ActionBar with unknown error?

P.S android studio新手

最佳答案

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

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

为此:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

不知道为什么,但它有效

关于android - 无法在 android studio 3.1.4 中加载 AppCompat ActionBar 并出现未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51805505/

相关文章:

android - 开发人员错误验证 Gmail 登录 Android - 异常 10

android - 使所有 EditText 不可一起编辑

Android NDK C++ 异常抛出 SIGSEGV 和 __gnu_cxx::__verbose_terminate_handler

android-studio - Android Studio 多进程运行

properties - Gradle中不同类型的属性?

android - 直接使用 libmedia\AudioFlinger 录制\播放音频

java - 无法导入 android.support.v4.content.ContextCompat

android - 可疑转换为 CLIPBOARD_SERVICE : expected ClipboardManager [ServiceCast] 的文本

java - 从 Gradle 运行 Protractor 测试

android - 从 Android Studio 中的 Gradle 项目向 VCS 提交的内容