I want to use a popup menu in my application, which should be compatible with Android 1.6+. Therefore, I use this code (taken from Support for different versions of the platform ) to distinguish between pre-Honeycomb (which does not have PopupMenu ) and Honeycomb + to display a pop-up window or AlertDialog:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { PopupMenu popup = new PopupMenu(this, v); ... } else { showDialog(DIALOG_ID); }
This works great with emulated Android 2.1 (showing AlertDialog), 2.3.3 (showing AlertDialog) and 4.2.2 (showing PopupMenu). However, it does not work with emulated Android 1.6. I get these error messages:
E/dalvikvm(211): Could not find class 'android.widget.PopupMenu', referenced from method ... W/dalvikvm(211): VFY: unable to resolve new-instance 50 (Landroid/widget/PopupMenu;) in L...; W/dalvikvm(211): VFY: rejecting opcode 0x22 at 0x0006 W/dalvikvm(211): VFY: rejected L...;.... (Landroid/view/View;)V W/dalvikvm(211): Verifier rejected class L...; W/dalvikvm(211): Class init failed in newInstance call (L...;)
Why is Android 2.x behaving as expected, but Android 1.6 is not working?
source share