【问题标题】:1-Failed to load AppCompat ActionBar with unknown error. 2-Failed to find style 'floatingActionButtonStyle' in current theme1-加载 AppCompat ActionBar 失败,出现未知错误。 2-在当前主题中找不到样式“floatingActionButtonStyle”
【发布时间】:2018-08-02 06:31:18
【问题描述】:

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>

【问题讨论】:

    标签: android xml android-layout android-studio android-appcompat


    【解决方案1】:

    粘贴这两个依赖项

    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'
    

    测试版导致问题。

    【讨论】:

    • 解析失败:com.android.support:appcompat-v7:28.0.0
    • 尝试降低依赖版本。
    猜你喜欢
    • 1970-01-01
    • 2018-12-05
    • 1970-01-01
    • 1970-01-01
    • 2018-12-12
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    相关资源
    最近更新 更多