java - Error: Didn't find class android.view.menu (on path) -


i'm trying create single menu item. when run app, crashes right when starts , following error in logcat:

e/androidruntime(1507): caused by: java.lang.classnotfoundexception: didn't find class "android.view.menu" on path: /data/app/com.thing.appname-2.apk

here xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android">         <item android:id="@+id/addeventmenu"               android:title="add event"               android:icon="@drawable/addeventimage"/>     </menu> 

the following outside of oncreate method (don't know if makes difference):

public boolean onoptionsitemselected(menuitem item) {         switch (item.getitemid()) {             case r.id.addeventmenu:                 //do here when menu button pressed                 return true;             default:                 return super.onoptionsitemselected(item);         }     }      @override     public boolean oncreateoptionsmenu(menu menu) {         menu.add(r.id.addeventmenu);         return super.oncreateoptionsmenu(menu);     } 

i've tried , same error:

@override public boolean oncreateoptionsmenu(menu menu) {     menuinflater inflater = getmenuinflater();     inflater.inflate(r.menu.main, menu);     return true; } 

i ran same problem before when started android development...

there different xml file under "menu" in project resources - much different layout xml file. put <menu> , <item>(s) in "res/menu/main.xml".

also, android studio has odd way of telling import stuff... make sure use

@override public boolean oncreateoptionsmenu(menu menu) {     menuinflater inflater = getmenuinflater();     inflater.inflate(r.menu.main, menu);     return true; } 

and click on red notification import.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -