AlertDialog按钮不存在

Mic*_*ert 4 android android-dialog

突然(这个项目代码没有任何变化)我开始得到一个错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{<package>}: java.lang.IllegalArgumentException: Button does not exist
Run Code Online (Sandbox Code Playgroud)

该错误指向尚未调用的方法.

private void dialog(String title, String content){
    AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(content);
    alertDialog.setCancelable(true);
    alertDialog.setButton(1, "OK", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
               dialog.dismiss();
               }
            });
    alertDialog.show();
}
Run Code Online (Sandbox Code Playgroud)

我试图在其他项目中复制并使用该代码 - 结果相同,并且它不久前工作(相同的目标API等).知道我在忽视什么吗?