error on lines:
getMenuInflater().inflate(, menu);

error: ----- R cannot be resolved to a variable

package com.example.android_01;

import android.os.Bundle;
import android.view.Menu;
import android.widget.EditText;

public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {

public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(, menu);
return true;

note i also tried importing:

import com.example.android_01.R;

but didnt worked.

i than try adding:

import android.R;

but than i got another error:" activity_main cannot be resolved or is not a field" on line:


Recommended Answers

All 2 Replies

check for updates than this issue will be resolved.Also don;t import R of import android.R;
If it is there than just remove it.
I also faced similar issue.I got it resolved by updating android version.

Select Project from the menu then Clean>>Build automatically if you're using Eclipse

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.