-4

i am new in android .The error is showing on this line of code, please help me how to solve this error

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;

}

Thank you sir!

  • it should be `menu_main.xml` whatever xml resided in res/menu subfolder – rafsanahmad007 Feb 20 '17 at 09:36
  • I did change , but still same error – Manoj Gayakwad Feb 20 '17 at 09:42
  • 1
    Possible duplicate of [Android - activity\_main cannot be resolved or is not a field](http://stackoverflow.com/questions/16995402/android-activity-main-cannot-be-resolved-or-is-not-a-field) – shadygoneinsane Feb 20 '17 at 09:53
  • Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(junit.framework.TestResult$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Information:BUILD FAILED – Manoj Gayakwad Feb 20 '17 at 11:06

2 Answers2

0

Are you sure you have activity_main.xml menu file?

Menu file looks like:

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

check your import statement

import android.R;

it should be

import yourpackage.R;

Ranjith KP
  • 858
  • 6
  • 18