title: Strange error (could not find method) on Android 1.6 only
body: <p>I've tried to add the following class to my app:</p>
  
  <pre><code>public class AlertDialogHelper {
  
      public static AlertDialog.Builder getDarkDialogBuilder(Context context) {
          if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
              int alertDialogTheme = AlertDialog.THEME_HOLO_DARK;
  
              if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                  alertDialogTheme = AlertDialog.THEME_DEVICE_DEFAULT_DARK;
              }
  
              return new AlertDialog.Builder(context, alertDialogTheme);
          }
  
          return new AlertDialog.Builder(context);
      }
  
      public static AlertDialog getDeleteNoteDialog(Context context, OnClickListener deleteListener) {
          AlertDialog.Builder builder = new AlertDialog.Builder(context);
  
          builder.setMessage(R.string.dialog_delete_message);
  
          builder.setPositiveButton(R.string.button_delete, deleteListener);
  
          builder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
  
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
              }
  
          });
  
          return builder.create();
      }
  
  }
  </code></pre>
  
  <p>Whenever and wherever I call <code>AlertDialogHelper.getDeleteNoteDialog(this, null)</code> while running on Android 1.6, I get the following error:</p>
  
  <pre><code>03-28 18:56:07.828: E/dalvikvm(303): Could not find method android.app.AlertDialog$Builder.&lt;init&gt;, referenced from method net.ricardoamaral.apps.notificationagenda.AlertDialogHelper.getDarkDialogBuilder
  03-28 18:56:07.828: W/dalvikvm(303): VFY: unable to resolve direct method 40: Landroid/app/AlertDialog$Builder;.&lt;init&gt; (Landroid/content/Context;I)V
  03-28 18:56:07.828: W/dalvikvm(303): VFY:  rejecting opcode 0x70 at 0x0010
  03-28 18:56:07.828: W/dalvikvm(303): VFY:  rejected Lnet/ricardoamaral/apps/notificationagenda/AlertDialogHelper;.getDarkDialogBuilder (Landroid/content/Context;)Landroid/app/AlertDialog$Builder;
  03-28 18:56:07.828: W/dalvikvm(303): Verifier rejected class Lnet/ricardoamaral/apps/notificationagenda/AlertDialogHelper;
  </code></pre>
  
  <p>This works just fine on any other version above 1.6. To be honest I only tested this on 2.1, 2.3 and 4.0. I assume it also works on all others (it might not be true though).</p>
  
  <p>If I comment the first method in the <code>AlertDialogHelper</code> class (the one the error is complaining about), the error goes way. But I need that method for other things and the error shows up anyway if I call that method too.</p>
  
  <p><strong>SOLUTION WITHOUT REFLECTION:</strong></p>
  
  <p>To fix the problem I've added the following class as nested-class to <code>AlertDialogHelper</code>:</p>
  
  <pre><code>private static class Compatibility {
      public static AlertDialog.Builder createAlertDialogBuilder(Context context, int alertDialogTheme) {
          return new AlertDialog.Builder(context, alertDialogTheme);
      }
  }
  </code></pre>
  
  <p>Then, in the <code>getDarkDialogBuilder</code> method, instead of calling this:</p>
  
  <pre><code>return new AlertDialog.Builder(context, alertDialogTheme);
  </code></pre>
  
  <p>I call this:</p>
  
  <pre><code>return Compatibility.createAlertDialogBuilder(context, alertDialogTheme);
  </code></pre>
  
  <p>This is how I've been fixing similar problems and so far I haven't had any issues with this method.</p>