Android – Attribute fab Attached not found

androidmaterial-design

Unable to run project when I am using material components.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'android.arch.lifecycle:extensions:1.1.1'

    implementation 'com.facebook.fresco:fresco:1.11.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation  'com.fxn769:pix:1.2.5'




    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'

}

Error Logs:

Android resource linking failed Output: D:\Android
Projects\Ghar3\app\src\main\res\layout\main_layout.xml:23: error:
attribute fabAttached (aka com.recreation.ghar:fabAttached) not found.
error: failed linking file resources.

Command: C:\Users\Abdul
Qadir.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\93d85fd8448aa5b91b30eb47e2faac6a\aapt2-3.2.1-4818971-windows\aapt2.exe
link -I\
D:\sdk\Android\sdk\platforms\android-28\android.jar\
–manifest\
D:\Android Projects\Ghar3\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
D:\Android Projects\Ghar3\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@D:\Android Projects\Ghar3\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
–auto-add-overlay\
–java\
D:\Android Projects\Ghar3\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
–custom-package\
com.recreation.ghar\
-0\
apk\
–output-text-symbols\
D:\Android Projects\Ghar3\app\build\intermediates\symbols\debug\R.txt\
–no-version-vectors Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

Best Solution

It looks like this attribute has been removed in androidx. To attach the action bar just add the attribute app:layout_anchor to your fab.

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        app:fabSize="normal"
        android:src="@drawable/ic_add_white_24dp"
        app:layout_anchor="@id/bottom_app_bar"/>
Related Question