Geofire crashes when writing to Firebase


Geofire crashes when writing to Firebase



I am writing a program to upload a LatLng data of the user to Firebase. It works by clicking a button btnAddPickUpLocation and it uploads to database. The user details and Uid has been initiated in other part of the codes and there is no issues with it.



The Lat Lng is currently hardcoded so it is not due to this variable source.



It returns perfectly when i set a Toast to return the Uid and it does not crash when i comment out



mGeofire.setLocation(Uid, new GeoLocation(37.7853889, -122.4056973));


mGeofire.setLocation(Uid, new GeoLocation(37.7853889, -122.4056973));



Any idea what is wrong with this statement?



The relevant codes are as follows.


RelativeLayout contentView = findViewById(R.id.contentView);
btnAddPickUpLocation = contentView.findViewById(R.id.btnAddPickUpLocation);
btnAddPickUpLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//AddPickUpLocation(FirebaseAuth.getInstance().getCurrentUser().getUid());

String Uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

Toast.makeText(getApplicationContext(), "hello " + Uid, Toast.LENGTH_LONG).show();
//addPickUpLocation(FirebaseAuth.getInstance().getCurrentUser().getUid());

dbAddPickUpLocation = FirebaseDatabase.getInstance().getReference("Favourites");

mGeofire = new GeoFire(dbAddPickUpLocation);

mGeofire.setLocation(Uid, new GeoLocation(37.7853889, -122.4056973));

}



Exception Details as follows



06-29 16:31:55.992 24528-24528/com.abc.getataxi E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.abc.getataxi, PID: 24528
java.lang.NoSuchMethodError: No virtual method setValue(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/firebase/tasks/Task; in class Lcom/google/firebase/database/DatabaseReference; or its super classes (declaration of 'com.google.firebase.database.DatabaseReference' appears in /data/app/com.abc.getataxi-51bdN05Z7tlQu3bNLaX2nQ==/split_lib_dependencies_apk.apk)
at com.firebase.geofire.GeoFire.setLocation(GeoFire.java:182)
at com.firebase.geofire.GeoFire.setLocation(GeoFire.java:154)
at com.abc.getataxi.UserMainPage$2.onClick(UserMainPage.java:299)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)





idownvotedbecau.se/noexceptiondetails
– Sander
Jun 29 at 16:06




1 Answer
1



managed to solve it by a work around. For any guys looking, add a completion listener parameters like below.


mGeofire.setLocation(Uid, new GeoLocation(37.7853889, -122.4056973), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {
Toast.makeText(getApplicationContext(), "Done ", Toast.LENGTH_LONG).show();
}
});






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift