-1

Full Code:

  package restfulapiclient.tutecentral.com.restfulapiclient;

    import android.app.ActionBar;
    import restfulapiclient.tutecentral.com.restfulapiclient.R;
    import android.net.Uri;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.app.Activity;
    import android.util.Log;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.support.v4.app.NavUtils;
    import android.annotation.TargetApi;
    import android.content.Intent;
    import android.os.Build;



   ......
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.create_user, menu);
            return true;
        }

        .......

Error Code :

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

Error Message :

Error:(150, 36) error: cannot find symbol variable menu

İnfo :

-Android Studio

-Example project

Cœur
  • 37,241
  • 25
  • 195
  • 267
Gökhan Polat
  • 19
  • 1
  • 7

5 Answers5

2

I know this post is some years old, but I was having the same problem and was unable to find the solution, so adding the steps that helped me resolve the issue to the thread just in case anyone else stumbles across this in future.

Solution: All you need to do is

  1. click the option "Invalidate Cache/Restart..."
  2. On the options menu that pops up, click "Invalidate and Restart"

And on restart of Android Studio, R.menu will become traceable.

Android Studio 3.6.3

james
  • 59
  • 5
1

try to remove menu.xml (inside res folder) errors then clean and build... it will work..

vijay chhalotre
  • 396
  • 2
  • 11
0

If you won’t to create menu then create menu folder in res and then create create_user xml under menu folder.

res->menu->create_user.xml

create_user.xml like this

    <menu xmlns:android="http://schemas.android.com/apk/res/android" >

        <item
            android:showAsAction="never"
            android:title="@string/action_settings"/>

    </menu>
David Passmore
  • 6,089
  • 4
  • 46
  • 70
Komal12
  • 3,340
  • 4
  • 16
  • 25
0

ProjectName\app\src\main\res\menu

follow above hierarchy and create create_user.xml file inside menu folder if menu folder in not there then create menu folder inside res.

vijay chhalotre
  • 396
  • 2
  • 11
0

Import Proper R Library:

import com.fha.blinkbook2022.R; Like This My Error Resolve When we import proper library

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 23 '22 at 10:26