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
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
A floating action button (FAB) is a circular button that triggers the primary action in your app's UI.
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.
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)
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.
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
@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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With