Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot resolve symbol 'FloatingActionButton'

Recently I have downloaded a code from GitHub and synced it with my android studio. I have faced lots of errors and issues while doing so and somehow fixed most of them. However, the last issue I'm stuck at right now is that my android studio cannot find the class FloatingActionButton as you can see in this screenshot screenshot

It is to be noted that earlier many other classes, including 'AppCompatActivity' could not be resolved. Changing the dependencies to following solved the issue

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'
}

But even after changing dependencies, clean building the project, doing 'Invalidate Caches / Restart...', the problem with 'FloatingActionButton' is still there.

You can check the repository here And this is the java code of the activity where the error is occurring

like image 409
ganjaam Avatar asked Jun 23 '18 03:06

ganjaam


People also ask

What is a Floating Action Button?

A floating action button (FAB) is a circular button that triggers the primary action in your app's UI.

Where is the floatingactionbutton in Android Studio?

The FloatingActionButton is in the design library. Show activity on this post. @Sub 6 Resources already answered this question wholly but I want to add a bonus tip. If you already added implementation 'com.android.support:design:27.1.1' to your code and the compiler can't still resolve the FloatingActionButton class, simply rebuild your project.

How do I set the size of the floatingactionbutton?

Indicates that the FloatingActionButton should not have a custom size, and instead that the size should be calculated based on the value set using setSize (int) or the fabSize attribute. Instead of using this constant directly, you can call the clearCustomSize () method. Constant Value: 0 (0x00000000)

Should floatingactionbutton add padding on Lollipop?

Set whether FloatingActionButton should add inner padding on platforms Lollipop and after, to ensure consistent dimensions on all platforms. Returns whether this fab will expand its bounds (if needed) to meet the minimum touch target size. Shows the button.


2 Answers

The FloatingActionButton is in the design library.

Add this line to your dependencies:

implementation 'com.android.support:design:27.1.1'

This post also has more general info about FloatingActionButton: FloatingActionButton example with Support Library

like image 166
Sub 6 Resources Avatar answered Sep 19 '22 03:09

Sub 6 Resources


@Sub 6 Resources already answered this question wholly but I want to add a bonus tip. If you already added implementation 'com.android.support:design:27.1.1' to your code and the compiler can't still resolve the FloatingActionButton class, simply rebuild your project. A colleague and I recently had this same problem while the dependency was already there and a simple rebuild solved it all.

like image 43
Taslim Oseni Avatar answered Sep 17 '22 03:09

Taslim Oseni