1

if anyone could help, I'm following the code line per line exactly like in this Uber tutorial and when I run the app I get this error:

NoSuchMethodError: No virtual method removeValueAsync() ...

I can't think of how to resolve the issue.

I've checked my gradle dependencies and everything seems to be fine, but can't get rid of this error no matter what I do...

If anyone can shed some light that we be great.

Maybe zygote error, I don't know.

It's the line right under 'case"":'

Thanks in advance!

 private void onLocationChanged(Location location) {
       if (getApplicationContext() != null){

           mLastLocation = location;
           LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
           mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
           mMap.animateCamera(CameraUpdateFactory.zoomTo(14));

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

                   break;

                   default:
                       geoFireAvailable.removeLocation(userId);
                       geoFireWorking.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()));

                       break;
           }
       }

 }
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'com.google.firebase:firebase-auth:19.0.0'
    implementation 'com.google.firebase:firebase-database:19.1.0'
    implementation 'com.firebase:geofire-java:3.0.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.firebase:geofire-java:3.0.0'
}

LOGCAT:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.e.uber, PID: 31292 java.lang.NoSuchMethodError: No virtual method setValueAsync(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/api/core/ApiFuture; in class Lcom/google/firebase/database/DatabaseReference; or its super classes (declaration of 'com.google.firebase.database.DatabaseReference' appears in /data/app/com.e.uber-0-WjkWsr0B0ZTV9sQ3Dsgg==/base.apk) at com.firebase.geofire.GeoFire.setLocation(GeoFire.java:178) at com.firebase.geofire.GeoFire.setLocation(GeoFire.java:149) at com.e.uber.DriverMapActivity.onLocationChanged(DriverMapActivity.java:177) at com.e.uber.DriverMapActivity.access$300(DriverMapActivity.java:47) at com.e.uber.DriverMapActivity$4.onLocationResult(DriverMapActivity.java:155) at com.google.android.gms.internal.location.zzau.notifyListener(Unknown Source:4) at com.google.android.gms.common.api.internal.ListenerHolder.notifyListenerInternal(com.google.android.gms:play-services-base@@17.1.0:17) at com.google.android.gms.common.api.internal.ListenerHolder$zaa.handleMessage(com.google.android.gms:play-services-base@@17.1.0:6) at android.os.Handler.dispatchMessage(Handler.java:112) at com.google.android.gms.internal.base.zar.dispatchMessage(com.google.android.gms:play-services-base@@17.1.0:8) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

user2342558
  • 5,567
  • 5
  • 33
  • 54

1 Answers1

1

Did you checked if the version of FirebaseUI you are using is compatible with the other Firebase and Google Play libraries?

Here https://github.com/firebase/FirebaseUI-Android#compatibility-with-firebase--google-play-services-libraries you can find a compatibility table.

Also, if you are running your app in the emulator, check if it uses the most recent version for Google Play Services.

user2342558
  • 5,567
  • 5
  • 33
  • 54