首页 > 解决方案 > 1-加载 AppCompat ActionBar 失败,出现未知错误。2-在当前主题中找不到样式“floatingActionButtonStyle”

问题描述

1-加载 AppCompat ActionBar 失败,出现未知错误。

2-在当前主题中找不到样式“floatingActionButtonStyle”。

XML 文件显示上述两个错误以及以下内容 -

1-缺少样式。是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用。

2-无法实例化以下类:- android.support.v7.widget.ActionBarContainer

- android.support.v7.widget.ActionBarContextView

- android.support.v7.app.WindowDecorActionBar

- android.support.design.widget.TextInputLayout

类路径是:

   classpath 'com.android.tools.build:gradle:3.1.3'
   classpath 'com.google.gms:google-services:4.0.2'



dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

//add library
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'

}
apply plugin: 'com.google.gms.google-services

XML 文件 -

   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"

tools:context=".MainActivity">

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:focusable="true"
    android:src="@drawable/ic_send"
    android:id="@+id/fab"
    android:tint="@android:color/white"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    app:fabSize="mini"
    />
<android.support.design.widget.TextInputLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:layout_toLeftOf="@+id/fab"
    android:layout_alignParentBottom="true"

    android:layout_toStartOf="@+id/fab"
    android:layout_alignParentStart="true"

    android:layout_alignParentLeft="true"
    >

    <EditText
        android:id="@+id/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Message..."
        android:inputType="text" />

</android.support.design.widget.TextInputLayout>

<ListView
    android:id="@+id/list_of_message"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:layout_above="@+id/fab"
    android:dividerHeight="16dp"
    android:divider="@android:color/transparent"
    android:layout_marginBottom="16dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true">

</ListView>

</RelativeLayout>

标签: androidxmlandroid-layoutandroid-studioandroid-appcompat

解决方案


粘贴这两个依赖项

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'

代替

implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'

测试版导致问题。


推荐阅读