Skip to content Skip to sidebar Skip to footer

Cannot Find Symbol Error On Android Studio

public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView

Solution 1:

It means you are missing the variables with id menu and action_settings in your resources/menu folder.

Solution 2:

You are having two errors:

getMenuInflater().inflate(R.menu.menu_main, menu);

and here

if (id == R.id.action_settings)

Basically, Android Studio is not generating R.menu items... I believe then, there's no file inside /res/menu/ (and according to your code, it should exist a /res/menu/menu_main.xml file.

So, I see two possibilities:

Remove menu code

Since you don't have /res/menu/menu_main.xml file, it seems that you are not using a Menu... So, remove public boolean onCreateOptionsMenu(Menu menu) and public boolean onOptionsItemSelected(MenuItem item) methods from your MainActivity.java

Create menu file

If you want to use a Menu, you must create a file under /res/menu/menu_main.xml and configure it properly... That file should have at least one item with ID android:id="@+id/action_settings"

Post a Comment for "Cannot Find Symbol Error On Android Studio"