oddmeter oddmeter - 1 month ago 55
Android Question

Android error during build - "default public constructor with no argument must be declared". What's the cause?

Android studio returned an error during build, even after running Clean, and rebuilding:


A default public constructor with no argument must be declared if a
custom constructor is declared.


I could not find a line number, nor a file referenced. I have no idea what causes this, as there's no indication from the build where or what the cause of this is.

Answer

Example :

public class ModelResult {
String Ques;
String Ans;

public String getQues() {
    return Ques;
}

public void setQues(String ques) {
    Ques = ques;
}

public String getAns() {
    return Ans;
}

public void setAns(String ans) {
    Ans = ans;
}


public ModelResult(String ques, String ans) {
    super();
    Ques = ques;
    Ans = ans;
}

public ModelResult() {
    super();
    // TODO Auto-generated constructor stub
}
}

your missing part may be this

public ModelResult() {
    super();
    // TODO Auto-generated constructor stub
}
Comments