Error:(28) Error: This class should provide a defa

2019-09-10 10:00发布

问题:

Everything went fine while compiling in debug mode. But while compiling in Release configuration, following error occurs :

Error:(28) Error: This class should provide a default constructor (a public constructor with no arguments) (myclassname.HelpDialog) [Instantiatable]

This is the code

public class HelpDialog extends Dialog {

    Activity mActivity;
    Button btn_go_back;   

    public HelpDialog(Activity mactivity) {
        super();
        this.mActivity = mactivity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.dialog_help);   

        btn_go_back = (Button)findViewById(R.id.btn_help_go_back);

        btn_go_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}

回答1:

Add this bro:

public HelpDialog( ){ 
  super(null);
}