Search code examples
androidandroid-appcompatfloating-action-button

In current theme failed to find style 'floatingActionButtonStyle'


Failed to find style 'floatingActionButtonStyle' in current theme.

I even tried doing this in my style.xml

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item>
</style>

It did not work. I used Base.theme because of appcompat problem I was facing . My appcompat is - 'com.android.support:appcompat-v7:28.0.0-alpha1

Here is the XML file where error is shown:

<?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>

Build.gradle(app)

  apply plugin: 'com.android.application'

    android {

    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.hp.chatapp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    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:27.1.1'
   // implementation 'com.firebaseui:firebase-ui-database:4.1.0'

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

Solution

  • After all the comments this is what I came up to:

    apply plugin: 'com.android.application'
    
    android {
    
        compileSdkVersion 27
        defaultConfig {
            applicationId "com.example.hp.chatapp"
            minSdkVersion 16
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
    
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        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:27.1.1'
        // implementation 'com.firebaseui:firebase-ui-database:4.1.0'
        // consider using implementation 'com.firebaseui:firebase-ui-database:3.1.1'
        // see the question below
    
    }
    
    apply plugin: 'com.google.gms.google-services'
    

    I suggest using compileSdkVersion and targetSdkVersion 27 because, as you noticed,

    28.0.0-alpha1 doesnt support FloatingActionButton style.

    and might also cause problems as it is in alpha version.

    Question about firebase-ui-database here.

    Extra: You can search for libraries here and see how many people are using it or the release date.