Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol 'menu' errors in Android Studio

Tags:

java

android

xml

I'm learning Android Development for Beginners from Udacity and have completed making an app named Court Counter in which I wrote code for an XML (activity_main.xml) and some code for Java (MainActivity.java) file as some of the code was provided by the Udacity team on Github.

But when I click on 'Build APK' I get two errors both from the Java file:

  1. Cannot resolve symbol 'menu' in the following code:-

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }
    
  1. Cannot resolve symbol 'action_settings':-

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
    
        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }
    
        return super.onOptionsItemSelected(item);
    }
    

I don't know what happens when these block of code are executed but I want to run the app on my phone!

like image 312
Kvaibhav01 Avatar asked Jul 06 '16 14:07

Kvaibhav01


1 Answers

With more than 20 years of experiencie i can tell you a very difficult solution for the menu problem on android studio...:

*********** Close the project an open it again ************************

like image 85
Toni fernandez Avatar answered Sep 30 '22 07:09

Toni fernandez