简体   繁体   English

无法加载具有未知错误的AppCompat ActionBar

[英]Failed to load AppCompat ActionBar with unknown error

My project can't render the layout in preview. 我的项目无法在预览中呈现布局。 My Android Studio version 3.1.2. 我的Android Studio版本3.1.2。 Im using API 28. This my activity_main.xml 我正在使用API​​ 28.这是我的activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/frame_container">

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="Hello World"
    android:gravity="center"/>
</android.support.constraint.ConstraintLayout>

It's simple, just to print Hello World to layout, but it can't show. 这很简单,只是将Hello World打印到布局,但它无法显示。 The error like below : 错误如下: 预览错误

I search the solve problem, the solution is using API 26. And i try, everything is normal, preview success. 我搜索解决问题,解决方案是使用API​​ 26.我尝试,一切正常,预览成功。 But i create Fragment Activity , the problems come back, preview can't show. 但是我创建片段活动 ,问题又回来了,预览无法显示。 If you have new solution, please help me! 如果您有新的解决方案,请帮助我!

I met the same problem recently despite it being a wizard simple project. 我最近遇到了同样的问题,尽管它是一个精灵简单的项目。

I tried with 23 level (Mashmallow) without any changes. 我尝试了23级(Mashmallow)没有任何变化。 I uninstalled Android Studio, reinstalled it, it made no changes, error was still there... 我卸载了Android Studio,重新安装它,它没有做任何更改,错误仍然存​​在...

Then I realized the problem was coming from a dependency (probably recently updated from Google with an error). 然后我意识到这个问题来自一个依赖(最近可能是谷歌更新了一个错误)。 The solution is to use the previous release. 解决方案是使用以前的版本。

Go to File -> Project Structure -> Modules app -> Dependencies Tab. 转到文件 - >项目结构 - >模块应用程序 - >依赖项选项卡。 The default used by wizard during project creation is com.android.support:appcompat-v7:28.0.0-alpha3 项目创建期间向导使用的默认值为com.android.support:appcompat-v7:28.0.0-alpha3

Simply modify to com.android.support:appcompat- v7:27.1.1 简单修改到com.android.support:appcompat- V7:27.1.1

in app\\res\\values\\styles.xml change 在app \\ res \\ values \\ styles.xml中更改

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

to

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

( Render error in Android Studio 3.0 Layout Editor ) 在Android Studio 3.0布局编辑器中渲染错误

Everything is fine; 一切都好; just clean project and run it again. 只是清理项目并再次运行它。

Clean project option is under Build . 清洁项目选项位于Build下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AppCompat ActionBar加载失败,出现未知错误 - AppCompat ActionBar failed to load with unknown error 无法加载未知错误的AppCompat ActionBar? - Failed to load AppCompat ActionBar with unknown error? 无法加载带有未知错误android studio 3.0的AppCompat ActionBar - Failed to load AppCompat ActionBar with unknown error android studio 3.0 无法加载具有未知错误的AppCompat ActionBar.Android Studio 3.1.3 - Failed to load AppCompat ActionBar with unknown error.Android Studio 3.1.3 Android Studio无法加载具有未知错误的AppCompat ActionBar - Android Studio Failed to load AppCompat ActionBar with unknown error 无法在Android studio中加载具有未知错误的AppCompat ActionBar - Failed to load AppCompat ActionBar with unknown error in android studio 另一个“无法加载未知的AppCompat ActionBar”错误问题 - Another “Failed to load AppCompat ActionBar with unknown” error issue 无法在Android studio 3.1.4中加载具有未知错误的AppCompat ActionBar - Failed to load AppCompat ActionBar with unknown error in android studio 3.1.4 无法加载AppCompat ActionBar - Failed to load AppCompat ActionBar 1-无法加载未知错误的AppCompat ActionBar。 2-在当前主题中找不到样式&#39;floatingActionButtonStyle&#39; - 1-Failed to load AppCompat ActionBar with unknown error. 2-Failed to find style 'floatingActionButtonStyle' in current theme
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM