Android Firebase数据库异常

Android Firebase数据库异常,android,firebase,firebase-realtime-database,Android,Firebase,Firebase Realtime Database,下面是我打算从firebase数据库中读取位置类型数据项并将其存储在位置类型对象中的类。我甚至尝试将datasnapshot存储在类的一个对象中,该类在构造函数中有一个Location-type参数,我得到了相同的错误,即: “com.google.firebase.database.DatabaseException:类android.location.location缺少没有参数的构造函数” package com.example.aadi.sarthi; 导入android.content

下面是我打算从firebase数据库中读取位置类型数据项并将其存储在位置类型对象中的类。我甚至尝试将datasnapshot存储在类的一个对象中,该类在构造函数中有一个Location-type参数,我得到了相同的错误,即:

“com.google.firebase.database.DatabaseException:类android.location.location缺少没有参数的构造函数”

package com.example.aadi.sarthi;
导入android.content.Context;
导入android.content.Intent;
导入android.location.location;
导入android.os.Bundle;
导入android.support.annotation.Nullable;
导入android.support.v4.app.Fragment;
导入android.support.v7.widget.LinearLayoutManager;
导入android.support.v7.widget.RecyclerView;
导入android.util.Log;
导入android.view.LayoutInflater;
导入android.view.MenuItem;
导入android.view.view;
导入android.view.ViewGroup;
导入com.google.firebase.database.ChildEventListener;
导入com.google.firebase.database.DataSnapshot;
导入com.google.firebase.database.DatabaseError;
导入com.google.firebase.database.DatabaseReference;
导入com.google.firebase.database.FirebaseDatabase;
导入com.google.firebase.database.ValueEventListener;
导入java.util.ArrayList;
导入java.util.List;
公共类ActiveNotifications扩展了片段{
公共静态最终字符串通知\u MSG=“NOTIFICATION MSG”;
公共回收视图回收视图;
字符串用户界面;
公开名单结果;
公共用户适配器;
private DatabaseReference=FirebaseDatabase.getInstance().getReference();
私有数据库引用eventRef=reference.child(“事件”);
//创建由通知发送的意图
公共静态意图makeNotificationIntent(上下文,字符串消息){
意向意向=新意向(上下文,ActiveNotifications.class);
意向。额外通知(通知信息,信息);
返回意图;
}
@可空
@凌驾
创建视图时的公共视图(LayoutFlater充气机、@Nullable ViewGroup容器、@Nullable Bundle savedInstanceState){
视图=充气机。充气(R.layout.activity\u active\u通知,容器,false);
getMac();
结果=新的ArrayList();
recyclerView=(recyclerView)view.findViewById(R.id.notification\u列表);
recyclerView.setHasFixedSize(true);
LinearLayoutManager rlm=新的LinearLayoutManager(getActivity());
rlm.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(rlm);
/*
createNotifyListRowItem()*/
userAdapter=新的userAdapter(结果);
recyclerView.setAdapter(userAdapter);
updateList();
返回视图;
}
@凌驾
公共布尔值onContextItemSelected(MenuItem项){
开关(item.getItemId()){
案例0:
打破
案例1:
打破
}
返回super.onContextItemSelected(项目);
}
公共void updateList(){
最终数据库引用位置ref=reference.child(String.valueOf(user_mac)).child(“位置”);
最终位置userLoc=null;
最终位置eventLoc=null;
locationRef.addListenerForSingleValueEvent(新的ValueEventListener()){
@凌驾
公共void onDataChange(DataSnapshot DataSnapshot){
if(dataSnapshot.exists()){
Location Location=dataSnapshot.getValue(Location.class);
userLoc.set(位置);
}
}
@凌驾
已取消的公共void(DatabaseError DatabaseError){
}
});
eventRef.limitToFirst(2).addChildEventListener(新的ChildEventListener()){
@凌驾
公共void onChildAdded(DataSnapshot DataSnapshot,字符串s){
eventRef.push().child(“位置”);
Location Location=dataSnapshot.getValue(Location.class);
事件定位集(位置);

if(eventLoc.distanceTo(userLoc)您的Location类需要一个空构造函数

public Location () {}

您应该需要添加Location类的构造函数

 public Location() {

}

你需要在这里为你的代码示例添加一些上下文。在我看来,你需要阅读Location类的文档。
类android.Location.Location缺少一个没有参数的构造函数。
。看起来你不能在Firebase数据库中使用该类,那么,酷@toothlessreli是否也有相同的pr问题是,当我试图将datasnapshot存储在参数中包含位置类型变量的对象中时。@t在与Firebase数据库交互时,您不能使用任意Java/Android类。它不知道如何处理这些类,而且这些类通常不遵循Firebase的规则(公共字段/getter,无参数公共构造函数)。因此,您必须创建自己的类来捕获位置的相关信息。请参阅,您已经这样做了。但没有帮助。Android中还有一个名为“location”的类。请参阅。请确保导入了正确的类。如果将类重命名为其他类会更好。不,我没有名为“Location”的类,我编辑了导入的你所引用的Location类,你也可以在这里发布你的类吗?你是如何编辑Location类的?好的@Tingyik90已经编辑过了。不是吗work@Override受保护位置解析快照(DataSnapshot快照){返回快照;}尝试此尝试什么?@ArslanJaved
 public Location() {

}