首页 文章

写入Firebase时,Geofire崩溃了

提问于
浏览
0

我正在编写一个程序,将用户的LatLng数据上传到Firebase . 它通过单击按钮 btnAddPickUpLocation 工作,并上传到数据库 . 用户详细信息和Uid已在代码的其他部分启动,并且没有任何问题 .

Lat Lng目前是硬编码的,因此不是由于这个可变来源 .

当我设置Toast返回Uid时它会完美返回,当我注释掉它时它不会崩溃

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

知道这个陈述有什么问题吗?

相关代码如下 .

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));

        }

例外详情如下

06-29 16:31:55.992 24528-24528 / com.abc.getataxi E / AndroidRuntime:FATAL EXCEPTION:main进程:com.abc.getataxi,PID:24528 java.lang.NoSuchMethodError:没有虚方法setValue(Ljava /郎/对象; Ljava /郎/对象;)LCOM /谷歌/火力/任务/任务;在Lcom / google / firebase / database / DatabaseReference中;或者它的超类('com.google.firebase.database.DatabaseReference'的声明出现在/data/app/com.abc.getataxi-51bdN05Z7tlQu3bNLaX2nQ==/split_lib_dependencies_apk.apk)com.firebase.geofire.GeoFire.setLocation( GeoFire.java:182)位于com.abc.getataxi.UserMainPage $ 2.onClick(UserMainPage.java:299)的com.firebase.geofire.GeoFire.setLocation(GeoFire.java:154),位于android.view.View.performClick( View.java:6294)在android.view.Handler.dispatchMessage(Handler.java)的android.view.View $ PerformClick.run(View.java:24770)android.os.Handler.handleCallback(Handler.java:790) :99)在android.app.Looper.loop(Looper.java:164)的android.app.ActivityThread.main(ActivityThread.java:6494),位于com的java.lang.reflect.Method.invoke(Native Method) . android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

1 回答

  • 0

    设法通过解决方法来解决它 . 对于任何寻找的人,添加如下所示的完成侦听器参数 .

    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();
                        }
                    });
    

相关问题