gpt4 book ai didi

java - Realm 构建错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:59:31 27 4
gpt4 key购买 nike

使用 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.

注意:默认构造函数已存在于我的模型或 Java Bean 类中。

谁能帮我解决这个问题?

数据库问题.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

您可以将所需的默认构造函数添加到指定的类并返回检查。

改变

DataBaseQuestion() {
}

public DataBaseQuestion() {
}

关于java - Realm 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37373473/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com