Error Message:
C:\Users\c2c\Tutiorial\app\src\main\java\com\code2care\tutiorial\MainActivity.java:25: error: cannot find symbol
FloatingActionButton fab = findViewById(R.id.fab);
^
symbol: variable fab
location: class id
You would get the above error when you run your Android App on Android Studio, this is due to a compilation error that you have in your MainActivity.java file at like 25. You may have deleted the fab icon from the XML file but not in the code.
Solution:Remove the below lines of code from your MainActivity.java file
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
Run your App now it should work :) ... Happy Coding!!
More Posts related to Android,
- Check Internet Connection WIFI 4G is active on Android Programmatically
- Android Emulator cannot be opened because the developer cannot be verified. [M1 Mac]
- How to Change Android Toast Position?
- Fail to connect to camera service Android java RuntimeException
- How to create Custom RatingBar Android Programming Tutorial
- Fixing Android unknown error 961 while downloading app
- Android AlertDialog with Yes No and Cancel Button
- Share or Send SMS via Android Intent
- The Android Virtual Device myEmulator is currently running an emulator and cannot be deleted.
- Pass data between two Android Activities and access it using Intent
- SQLite with Android Easy to Understand Tutorial that covers Select, Insert, Update and Delete
- [FIX] AndroidRuntime: FATAL EXCEPTION: main - java.lang.RuntimeException NullPointerException
- Android EditText Cursor Colour appears to be white
- Android Development - How to switch between two Activities
- Android xml error Attribute is missing the Android namespace prefix [Solution]
- Android : Remove ListView Separator/divider programmatically or using xml property
- Android is starting optimizing... app 1 of 1
- java.lang.NoClassDefFoundError android.support.v4.content.LocalBroadcastManager
- AlertDialog with single button example : Android
- Android : Exception raised during rendering: action_bar API 22
- Maven : java.lang.ClassNotFoundException: Xmx512m
- Android Lint app_name is not translated in af (Afrikaans) am (Amharic) ar (Arabic) bg (Bulgarian)
- Center align text in TextView Android Programming
- How to Download and Install Android adb Tool on Linux, Mac or Windows
- Multiline EditText in Android Example
More Posts:
- How to make TextEdit the default text Editor on Mac - MacOS
- Test Timeout using JUnit 4 with examples - Java
- What is Terminal Velocity and its Formula? How to calculate it programmatically? - Python
- Fix - 412 Cookies Are Disabled error in Exchange Admin Center when you click hybrid - Microsoft
- Pass data between two Android Activities and access it using Intent - Android
- Python Sleep Function/Method Code Example - Python
- List of All 35 Reserved Keywords in Python Programming Language 3.11 - Python
- [Fix] brew: command not found Mac or Linux Terminal Error - MacOS