Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 65
Registered: ‎05-15-2011
My Device: 9700
My Carrier: Att
Accepted Solution

MenuItem error - NoClassDefFound

[ Edited ]

Hi,

 

I'm trying to add a MenuItem to my project:

protected void makeMenu (Menu menu, int instance ) {

super.makeMenu(menu, instance);

menu.add (new MyMenuItem());

}

 

class MyMenuItem extends MenuItem {

MyMenuItem() {

super(new StringProvider("Menu item text"), 100000, 0);

}

}

 

 

 

but when I click the Menu Button I receive NoClassDefFound


    Thanks,

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: MenuItem error - NoClassDefFound

Have you stepped through your code to see what is causing the problem?

 

Are you running on a suitable level of simulator given the OS level you have compiled with?

Regular Contributor
Posts: 65
Registered: ‎05-15-2011
My Device: 9700
My Carrier: Att

Re: MenuItem error - NoClassDefFound

I'm looking for a MenuItem which is suitable for OS 5.0 and above....

 

 

Highlighted
Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: MenuItem error - NoClassDefFound

5.0.0 does not have the MenuItem constructor that takes a StringProvider. That was only introduced in 6.0.0. Which means you are probably compiling for 6.0.0 and running on 5.0.0, which you shouldn't do.

Regular Contributor
Posts: 65
Registered: ‎05-15-2011
My Device: 9700
My Carrier: Att

Re: MenuItem error - NoClassDefFound

Thank you for your reply,

 

Fix me if I'm wrong:

 

If I want my app to be compatible with both OS 5.0 & 6.0 I need to check the OS version,

If 5.0

Create a MenuItem with the constructor of OS 5.0 - http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/MenuItem.html

if 6.0

Create a MenuItem with the constructor of OS 6.0 - http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/ui/MenuItem.html

 

 

???

 

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: MenuItem error - NoClassDefFound

mreed wrote
5.0.0 does not have the MenuItem constructor that takes a StringProvider. That was only introduced in 6.0.0. Which means you are probably compiling for 6.0.0 and running on 5.0.0, which you shouldn't do.

yes you can't pass stringprovider in menuItem constructor's if you use os5.0 you can surely use it for 6.0 and above it.....