ReactNative: 0.61.4 ReactNativeMaps: 0.26.1 Android: 7 ~ 10
Я обнаружил ошибку в FireBase Crashlytics
при использовании ReactNativeMaps.
com.google.maps.api.android.lib6.gmm6.api.m.a (:com.google.android.gms.dynamite_mapsdynamite@200616061@20.06.16 (100300-0):5)
com.google.maps.api.android.lib6.impl.dd.a (:com.google.android.gms.dynamite_mapsdynamite@200616061@20.06.16 (100300-0):12)
com.google.android.gms.maps.internal.ag.a (:com.google.android.gms.dynamite_mapsdynamite@200616061@20.06.16 (100300-0):1)
ch.onTransact (:com.google.android.gms.dynamite_mapsdynamite@200616061@20.06.16 (100300-0):4)
android.os.Binder.transact (Binder.java:692)
com.google.android.gms.internal.maps.zza.zzb (unkonwSource:20)
com.google.android.gms.maps.internal.zzai.zza (unkonwSource:5)
com.google.android.gms.maps.zzm.onLocationChanged (unkonwSource:2)
com.airbnb.android.react.maps.FusedLocationSource$1.onSuccess (FusedLocationSource.java:46)
com.airbnb.android.react.maps.FusedLocationSource$1.onSuccess (FusedLocationSource.java:43)
com.google.android.gms.tasks.zzn.run (unkonwSource:4)
android.os.Handler.handleCallback (Handler.java:873)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:205)
android.app.ActivityThread.main (ActivityThread.java:6996)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:884)
Не знаю Не знаю, где находится остальная часть кода. Поскольку известно только FusedLocationSource
, я видел FusedLocationSource
, но android.location.Location.getLatitude ()
не существует.
package com.airbnb.android.react.maps;
import android.content.Context;
import android.location.Location;
import android.os.Looper;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.LocationSource;
import com.google.android.gms.tasks.OnSuccessListener;
public class FusedLocationSource implements LocationSource {
private final FusedLocationProviderClient fusedLocationClientProviderClient;
private final LocationRequest locationRequest;
private LocationCallback locationCallback;
public FusedLocationSource(Context context){
fusedLocationClientProviderClient =
LocationServices.getFusedLocationProviderClient(context);
locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(5000);
}
public void setPriority(int priority){
locationRequest.setPriority(priority);
}
public void setInterval(int interval){
locationRequest.setInterval(interval);
}
public void setFastestInterval(int fastestInterval){
locationRequest.setFastestInterval(fastestInterval);
}
@Override
public void activate(final OnLocationChangedListener onLocationChangedListener) {
fusedLocationClientProviderClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
onLocationChangedListener.onLocationChanged(location);
}
});
locationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
for (Location location : locationResult.getLocations()) {
onLocationChangedListener.onLocationChanged(location);
}
}
};
fusedLocationClientProviderClient.requestLocationUpdates(locationRequest, locationCallback, Looper.myLooper());
}
@Override
public void deactivate() {
fusedLocationClientProviderClient.removeLocationUpdates(locationCallback);
}
}
Я знаю, что это ошибка, которая возникает внутри onSuccess
, но я не знаю, как это исправить. Помощь.