getting below error with building code with Realm
:app:compileDebugJavaWithJavac Note: Processing class DataBaseQuestion Error:A default public constructor with no argument must be declared if a custom constructor is declared. Note: Creating DefaultRealmModule Warning:File for type 'io.realm.DefaultRealmModule' created in the last round will not be subject to annotation processing. Warning:File for type 'io.realm.DefaultRealmModuleMediator' created in the last round will not be subject to annotation processing. 2 warnings Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Note: A default constructor is already present in my Model or Java Bean Class.
Can anyone please help me how to resolve this?
DataBaseQuestion.java
public class DataBaseQuestion extends RealmObject{
int id;
String Question =null;
String QuestionNo =null;
List<String> optionList=null;
String typeOfQuestion=null;
String Answer = null;
String Explanation = null;
DataBaseQuestion()
{
}
public DataBaseQuestion(int id, String question, String questionNo, List<String> optionList, String typeOfQuestion, String answer, String explanation) {
this.id = id;
Question = question;
QuestionNo = questionNo;
this.optionList = optionList;
this.typeOfQuestion = typeOfQuestion;
Answer = answer;
Explanation = explanation;
}
public String getQuestion() {
return Question;
}
public void setQuestion(String question) {
Question = question;
}
public String getQuestionNo() {
return QuestionNo;
}
public void setQuestionNo(String questionNo) {
QuestionNo = questionNo;
}
public List<String> getOptions() {
return optionList;
}
public void setOptions(List<String> optionList) {
this.optionList = optionList;
}
public String getTypeOfQuestion() {
return typeOfQuestion;
}
public void setTypeOfQuestion(String typeOfQuestion) {
this.typeOfQuestion = typeOfQuestion;
}
public String getAnswer() {
return Answer;
}
public void setAnswer(String answer) {
Answer = answer;
}
public String getExplanation() {
return Explanation;
}
public void setExplanation(String explanation) {
Explanation = explanation;
}
@Override
public String toString() {
return "DataBaseQuestion{" +
"Question='" + Question + '\'' +
", QuestionNo='" + QuestionNo + '\'' +
", options=" + optionList +
", typeOfQuestion='" + typeOfQuestion + '\'' +
", Answer='" + Answer + '\'' +
", Explanation='" + Explanation + '\'' +
'}';
}
Error:A default public constructor with no argument must be declared
You can add the desired default constructor
to the specified class and check back.
Change
DataBaseQuestion() {
}
to
public DataBaseQuestion() {
}