'Android Studio R.menu error
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
Solution 1:[1]
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
- click the option "Invalidate Cache/Restart..."
- On the options menu that pops up, click "Invalidate and Restart"
And on restart of Android Studio, R.menu will become traceable.
Solution 2:[2]
try to remove menu.xml (inside res folder) errors then clean and build... it will work..
Solution 3:[3]
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.
Solution 4:[4]
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>
Solution 5:[5]
Import Proper R Library:
import com.fha.blinkbook2022.R; Like This My Error Resolve When we import proper library
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | james |
Solution 2 | vijay chhalotre |
Solution 3 | vijay chhalotre |
Solution 4 | David Passmore |
Solution 5 | Hassam Saeed |