0

I have created an android application which runs perfectly in Samsung galaxy ace device. But when I run the same on HTC Desire V, it is giving FATAL EXCEPTION. Note: Samsung device is 3.5 inch screen device while HTC is 4 inch device. The error showing in logcat is as below:

FATAL EXCEPTION: main
java.lang.RuntimeException: Expecting menu, got ScrollView
at android.view.MenuInflater.parseMenu(MenuInflater.java:128)
at android.view.MenuInflater.inflate(MenuInflater.java:95)
at com.pixel.hp.activity.HandpumpActivity.onCreateOptionsMenu(HandpumpActivity.java:1476)
at android.app.Activity.onCreatePanelMenu(Activity.java:2508)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:407)
at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:762)
at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:3083)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

Is it because of change in screen size or something else? Any idea on this would be very helpful.

I am getting error in below method (2nd line is HandpumpActivity.java:1476) :

   public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_handpump, menu);
    return true;
}
Shrikant
  • 153
  • 1
  • 4
  • 19

1 Answers1

3

Make sure your activity_handpump.xml only contains <menu>, <item> or <group> elements. <ScrollView> should not be in activity_handpump.xml as per the Android documentation.

The only explanation on how it is working on Galaxy Ace that I could think of is that you are having different Layouts for menus loaded for different screen sizes (Ace is mdpi while Desire is hdpi)

Mohamed_AbdAllah
  • 5,311
  • 3
  • 28
  • 47
  • thanks for the reply. this may help me in some context. Will go through the link. – Shrikant Nov 07 '12 at 12:23
  • Apparently if you name a class as 'Menu' and rename it, all xml files that contains <'menu'> would rename it to the new name you refactored it to. – Hiroga Katageri Nov 28 '17 at 08:08