我的应用程序在单击按钮时崩溃,日志显示Firebase异常-“发现名称冲突的吸气剂:isChangingConfigurations”
这是课程。
public class tt extends AsyncTask<Void,Void,Void>
{ Member member = new Member();
DatabaseReference reff = FirebaseDatabase.getInstance().getReference().child("Member");
doit ok = new doit();
@Override
protected Void doInBackground(Void... voids) {
member.go();
ok.setAd_id(member.ad_id);
ok.setPrice(member.price);
ok.setUsername(member.username);
Thread thread = new Thread(new Runnable() {
@Override
public void run() { reff.push().setValue(ok);
}
});
thread.run();
return null;
}
这是日志...。
05-12 18:24:44.824 23423-24354/com.example.btc E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: com.example.btc, PID: 23423
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.google.firebase.database.DatabaseException: Found conflicting getters for name: isChangingConfigurations
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.<init>(com.google.firebase:firebase-database@@19.3.0:477)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.loadOrCreateBeanMapperForClass(com.google.firebase:firebase-database@@19.3.0:329)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.serialize(com.google.firebase:firebase-database@@19.3.0:166)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertToPlainJavaTypes(com.google.firebase:firebase-database@@19.3.0:60)
at com.google.firebase.database.DatabaseReference.setValueInternal(com.google.firebase:firebase-database@@19.3.0:282)
at com.google.firebase.database.DatabaseReference.setValue(com.google.firebase:firebase-database@@19.3.0:159)
at com.example.btc.tt$1.run(tt.java:24)
at java.lang.Thread.run(Thread.java:818)
at com.example.btc.tt.doInBackground(tt.java:30)
at com.example.btc.tt.doInBackground(tt.java:11)
答案 0 :(得分:0)
通过使用哈希图解决。...
public class tt extends AsyncTask<Void,Void,Void>
{ Member member = new Member();
DatabaseReference reff = FirebaseDatabase.getInstance().getReference().child("Member");
doit ok = new doit();
@Override
protected Void doInBackground(Void... voids) {
member.go();
ok.setAd_id(member.ad_id);
ok.setPrice(member.price);
ok.setUsername(member.username);
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
HashMap<String,String>
Student = new HashMap<>();
Student.put("Ad_id",ok.Ad_id);
Student.put("Price",ok.Price);
Student.put("Username",ok.Username);
reff.push().setValue(Student);
}
});
thread.run();
return null;
}
}