- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经关注了一些具有相同上下文的问题,但我仍然没有找到理解或发现此错误的方法。我正在尝试将数据发送到我的 Firebase 实时数据库。付款的总费用,在我的购物车中列出和用户名,但我仍然收到此错误。
com.google.firebase.database.DatabaseException: No properties to serialize found on class com.urbanx.urbaninsure.model.RequestDelivery
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.<init>(com.google.firebase:firebase-database@@19.1.0:530)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.loadOrCreateBeanMapperForClass(com.google.firebase:firebase-database@@19.1.0:312)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.serialize(com.google.firebase:firebase-database@@19.1.0:166)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertToPlainJavaTypes(com.google.firebase:firebase-database@@19.1.0:60)
at com.google.firebase.database.DatabaseReference.setValueInternal(com.google.firebase:firebase-database@@19.1.0:282)
at com.google.firebase.database.DatabaseReference.setValue(com.google.firebase:firebase-database@@19.1.0:159)
at com.urbanx.urbaninsure.InsurancePayment$1.onClick(InsurancePayment.java:255)
我的支付类
public class Payment extends AppCompatActivity implements View.OnClickListener {
LinearLayout InsurancePaymentLayout, MethodPaymentLayout, MpesaLayout, CreditCardLayout, EazzyPayLayout,
mpesaLayout, CreditBarLayout, EazzyPayBarLayout, PaymentStatementLayout,LAddress,
DeclinedPaymentStatementLayout,CompleteLayout, DeliveryLayout, hdCardLayout, cardLayout;
TextView tvCostStatement,tvCost, tvPay, tvAddress,etvAddress ;
TextView tvSerial, tvStroke, tvExpire, tvCardNumber;
RadioButton rbMpesa, rbCard, rbEazzy;
ProgressBar pbComplete;
Button bComplete, bDelivery, bPay;
ImageView ivMpesa, ivCredit;
EditText etCcn, etYear, etMonth, cd1, cd2, cd3, cd4;
List<ProposalDetails> cart = new ArrayList<>();
DatabaseHelper myDb;
CartAdapter adapter;
FirebaseDatabase database;
DatabaseReference requests;
CoordinatorLayout layout;
DatabaseReference mCustomerDatabase;
private FirebaseAuth mAuth;
private String totalPrice;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_insurance_payment);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
layout = (CoordinatorLayout)findViewById(R.id.layout);
LAddress = (LinearLayout)findViewById(R.id.LAddress);
etvAddress = (TextView) findViewById(R.id.etvAddress);
tvAddress = (TextView)findViewById(R.id.tvAddress);
bComplete = (Button)findViewById(R.id.bComplete);
bComplete.setOnClickListener(this);
cardLayout = (LinearLayout)findViewById(R.id.cardLayout);
cd1 = (EditText)findViewById(R.id.cd1);
cd2 = (EditText)findViewById(R.id.cd2);
cd3 = (EditText)findViewById(R.id.cd3);
cd4 = (EditText)findViewById(R.id.cd4);
ivCredit = (ImageView)findViewById(R.id.ivCredit);
hdCardLayout = (LinearLayout)findViewById(R.id.hdCardLayout);
tvCardNumber = (TextView)findViewById(R.id.tvCardNumber);
tvSerial = (TextView)findViewById(R.id.tvSerial);
tvStroke = (TextView)findViewById(R.id.tvStroke);
tvExpire =(TextView)findViewById(R.id.tvExpire);
etCcn = (EditText)findViewById(R.id.etCcn);
etMonth = (EditText)findViewById(R.id.etMonth);
etYear = (EditText)findViewById(R.id.etYear);
bPay = (Button)findViewById(R.id.bPay);
ivMpesa = (ImageView)findViewById(R.id.ivMpesa);
pbComplete = (ProgressBar)findViewById(R.id.pbComplete);
rbMpesa = (RadioButton)findViewById(R.id.rbMpesa);
rbMpesa.setOnClickListener(this);
rbCard = (RadioButton)findViewById(R.id.rbCard);
rbCard.setOnClickListener(this);
rbEazzy = (RadioButton)findViewById(R.id.rbEazzy);
rbEazzy.setOnClickListener(this);
tvCostStatement = (TextView)findViewById(R.id.tvCostStatement);
totalPrice = getIntent().getStringExtra("totalPrice");
tvCost = (TextView)findViewById(R.id.tvCost);
tvCost.setText(totalPrice);
tvCost.setText(totalPrice);
myDb = new DatabaseHelper(this);
adapter = new CartAdapter(cart,this);
database = FirebaseDatabase.getInstance();
requests = database.getReference("OrderRequests");
tvPay = (TextView)findViewById(R.id.tvPay);
InsurancePaymentLayout = (LinearLayout)findViewById(R.id.InsurancePaymentLayout);
MethodPaymentLayout = (LinearLayout)findViewById(R.id.MethodPaymentLayout);
MpesaLayout = (LinearLayout)findViewById(R.id.MpesaLayout);
CreditCardLayout = (LinearLayout)findViewById(R.id.CreditCardLayout);
EazzyPayLayout = (LinearLayout)findViewById(R.id.EazzyPayLayout);
mpesaLayout = (LinearLayout)findViewById(R.id.mpesaLayout);
mpesaLayout.setVisibility(View.GONE);
CreditBarLayout = (LinearLayout)findViewById(R.id.CreditBarLayout);
CreditBarLayout.setVisibility(View.GONE);
EazzyPayBarLayout = (LinearLayout)findViewById(R.id.EazzyPayBarLayout);
EazzyPayBarLayout.setVisibility(View.GONE);
PaymentStatementLayout = (LinearLayout)findViewById(R.id.PaymentStatementLayout);
PaymentStatementLayout.setVisibility(View.GONE);
DeclinedPaymentStatementLayout = (LinearLayout)findViewById(R.id.DeclinedPaymentStatementLayout);
CompleteLayout = (LinearLayout)findViewById(R.id.CompleteLayout);
CompleteLayout.setVisibility(View.VISIBLE);
DeliveryLayout = (LinearLayout)findViewById(R.id.DeliveryLayout);
bDelivery = (Button)findViewById(R.id.bDelivery);
bDelivery.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.rbMpesa:
if (rbMpesa.isChecked()){
rbCard.setChecked(false);
rbEazzy.setChecked(false);
mpesaLayout.setVisibility(View.VISIBLE);
CreditBarLayout.setVisibility(View.GONE);
EazzyPayBarLayout.setVisibility(View.GONE);
}
break;
case R.id.rbCard:
if (rbCard.isChecked()){
rbMpesa.setChecked(false);
rbEazzy.setChecked(false);
mpesaLayout.setVisibility(View.GONE);
CreditBarLayout.setVisibility(View.VISIBLE);
EazzyPayBarLayout.setVisibility(View.GONE);
}
break;
case R.id.rbEazzy:
if (rbEazzy.isChecked()){
rbMpesa.setChecked(false);
rbCard.setChecked(false);
mpesaLayout.setVisibility(View.GONE);
CreditBarLayout.setVisibility(View.GONE);
EazzyPayBarLayout.setVisibility(View.VISIBLE);
}
break;
case R.id.bComplete:
showAlertDialog();
break;
case R.id.bDelivery:
startActivity(new Intent(this, DeliveryActivity.class));
break;
}
}
private void showAlertDialog() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("Final step!");
alertDialog.setMessage("Enter your delivery location: ");
LayoutInflater inflater = LayoutInflater.from(this);
View destination_layout = inflater.inflate(R.layout.enter_address,null);
final EditText etAddress = destination_layout.findViewById(R.id.edtAddress);
alertDialog.setView(destination_layout);
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final android.app.AlertDialog waitingDialog = new SpotsDialog(InsurancePayment.this,"Placing ");
waitingDialog.show();
if (TextUtils.isEmpty(etAddress.getText().toString()))
{
Snackbar.make(layout,"Please enter delivery location", Snackbar.LENGTH_SHORT)
.show();
return;
}
String address = etAddress.getText().toString();
DeliveryRequest requestDelivery = new DeliveryRequest();
requestDelivery.setFirstNameProposer("am");
requestDelivery.setLastNameProposer("");
requestDelivery.setAddress("address");
// String json = gson.toJson(requestDelivery);
String requestId = requests.push().getKey();
requests.child(requestId)
.setValue(requestDelivery);
myDb.deleteAllInsurance();
myDb.deleteAllInsurance();
LAddress.setVisibility(View.VISIBLE);
etvAddress.setText(address);
waitingDialog.dismiss();
Toast.makeText(InsurancePayment.this,"Thank your, Order placed",Toast.LENGTH_SHORT).show();
PaymentStatementLayout.setVisibility(View.VISIBLE);
CompleteLayout.setVisibility(View.GONE);
pbComplete.setVisibility(View.VISIBLE);
DeliveryLayout.setVisibility(View.VISIBLE);
}
});
alertDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
dialogInterface.dismiss();
}
});
alertDialog.show();
}
@Override
public void onBackPressed() {
if ((pbComplete.getVisibility() == View.VISIBLE)&&(DeliveryLayout.getVisibility()==View.VISIBLE)) {
// Its visible
} else {
Intent openProposalForm = new Intent(InsurancePayment.this, Cart.class);
startActivity(openProposalForm);
finish();
// Either gone or invisible
}
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
}
我的 RequestDelivery 类
public class DeliveryRequest implements Serializable {
public String firstNameProposer, lastNameProposer,address;
public DeliveryRequest() {
}
public String getFirstNameProposer() {
return firstNameProposer;
}
public void setFirstNameProposer(String firstNameProposer) {
this.firstNameProposer = firstNameProposer;
}
public String getLastNameProposer() {
return lastNameProposer;
}
public void setLastNameProposer(String lastNameProposer) {
this.lastNameProposer = lastNameProposer;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
最佳答案
我以前没有使用过 firebase 数据库,但我使用过其他提供 JSON 响应的 API,或者我向服务器发送了 json 响应。因此,当您获取/发送 JSON 响应时,您需要告诉 Java 如何使用 @SerializedName
读取它。因此,例如,如果您收到这样的 json 响应:
{
phone:"12345678",
__total:"1000",
... ...
}
我认为在这种情况下,您需要像这样更改 RequestDelivery
类:
class RequestDelivery{
@SerializedName("phone") /* here this 'phone' is the string that is exactly in the json response*/
public String phone;
@SerializedName("__total") /* put __total because it is in my sample json. You change it according to your actual json response */
public String total;
... ... ...
}
请谷歌了解更多关于您应该为列表做什么的详细信息(代码中的提案详细信息)。我希望这有效。祝你好运。
关于java - firebase.database.DatabaseException : No properties to serialize found on class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58899548/
您好,下面是我在 AWS 中创建启用了弹性 IP 的实例的模板。但是我不确定我哪里出错了。我已经通过在线 json 验证器验证了 json,仍然面临问题请帮忙 { "AWSTemplateForm
标题有点乱,但已经说明了一切。我想在一个属性的属性上有一个属性观察器: class A { var b: B init() { b = B() } fu
假设我的一个 Controller 中有这样的方法: [Route("api/Products")] public IQueryable GetProducts() { return db.P
这有效: // @flow import React, {Component} from 'react'; type Props = {}; class Delete extends Componen
我有一个 ViewModelBase 类,我在其中为 INotifyPropertyChanged 接口(interface)定义了 RaisePropertyChanged 方法。大多数 MVVM
我创建了类: class StorageBase { public Queue Slices {get;set;} } 和 wpf 自定义控件,它具有 StorageBase 类型的依赖属性
我的 java 应用程序问题是 log4j2 系统日志不是写在 'local1.log' 中而是'消息'。我的/etc/rsyslog.conf 在/etc/rsyslog.conf 中配置为 'lo
为什么需要在对象中使用 this.property = property ?它是用来定义对象的“外部世界”的属性吗? function Person(property) { this.property
摘要: 这个问题是关于属性的继承与从彼此继承属性的类的内部和外部的不同读/写访问相结合。 详细信息: 我有一个类 A 和另一个继承自 A 的类 B。 A 中声明了属性someProperty。我希望该
我正在开发 ASP.NET MVC 应用,设计域模型,使用(测试)新的 EF Code First 功能。 我有一个可能有也可能没有截止日期的事件实体,处理它的最佳方法是什么? 1 个属性: publ
我在配置项目时经常使用它们,但大多数情况下都是按照指示添加 fragment 。我完全不知道哪个文件到底是做什么的。谁能清楚地说明每个文件的用途。 到目前为止我认为 local.properties
在运行 python 文件以使用 rasa nlu 训练文件时,我在命令提示符下收到此错误 我目前正在使用 Windows 10 rasa_core==0.8.2 rasa_nlu==0.11.4 p
我在这方面遇到了一些麻烦,尽管我已经搜索了答案,但还是找不到。 为了使用 AsyncAppender,我看到了很多不同的 log4j 配置,无论如何,它们都与 .properties 配置文件无关。
我正在编写一个 Python 类,并使用 @property 装饰器为该类创建属性。 我在文档中没有找到太多关于这个装饰器的信息,但是从我可以从 Stack Overflow 和我的 Python l
在 gradle 任务中,我可以创建这样的路径: System.env.FOLDER_PATH + '/subFolder' 但我想在我的 gradle.properties 中设置它,所以它会像 s
如何在属性文件的 log4j2 中创建键值对? 我知道在 log4j 版本 1 中它是这样完成的: log4j.appender.x.additionalFields={'key': 'value'}
我想通了 struct PropertyTest { @property int x() { return val; } @property void x( int newVal )
我有 REST (Jersey) webservice,它利用了一些编码/解码到/来自 XML 的数据对象。数据对象位于 webservice war 所依赖的单独项目/jar 中。 我使用 MOXy
我正在创建一个 LinkedList 类: function LinkedList(){ ... 有什么区别: this.addNode = function(data){
关于语义的快速问题:) 如果我正在编写一个协议(protocol),这是首选: // (a) @protocol MyProtocol @property (nonatomic, copy) NSSe
我是一名优秀的程序员,十分优秀!