gpt4 book ai didi

android - 如何修复 "java.lang.NoSuchMethodError: com.google.firebase.database.DatabaseReference.setValue"

转载 作者:行者123 更新时间:2023-11-29 23:22:30 24 4
gpt4 key购买 nike

我正在我的应用程序中设置当前位置。我需要在哪里设置编码?

    @Override
public void onLocationChanged(Location location) {
mLastLocation = location;
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));

//Geo Fire for current location
String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference refAvailable = FirebaseDatabase.getInstance().getReference("driversAvailable");
DatabaseReference refWorking = FirebaseDatabase.getInstance().getReference("driversWorking");

GeoFire geoFireAvailable = new GeoFire(refAvailable);
GeoFire geoFireWorking = new GeoFire(refWorking);

switch (customerId){
case "":

geoFireWorking.removeLocation(userId);
geoFireAvailable.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {

}
});

break;
default:
geoFireAvailable.removeLocation(userId);
geoFireWorking.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {

}
});

break;
}


}

以下是我得到的错误:

java.lang.NoSuchMethodError: com.google.firebase.database.DatabaseReference.setValue at com.firebase.geofire.GeoFire.removeLocation(GeoFire.java:215) at com.firebase.geofire.GeoFire.removeLocation(GeoFire.java:192) at com.example.webforest.quickaidlikeuber2nd.DriverMapActivity.onLocationChanged(DriverMapActivity.java:184)

最佳答案

Geofire 发生了一些变化,现在要使 removeLocation 起作用,您必须像这样添加一个监听器:

 //after updating 
geoFireWorking.removeLocation("id of the node you want to remove", new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {

}
});

关于android - 如何修复 "java.lang.NoSuchMethodError: com.google.firebase.database.DatabaseReference.setValue",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54003750/

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