The Fused Location Provider API seems to be broken on the Android Automotive Emulator image Sv2 (API 32, arm64-v8a, with Play Store). Does anyone know of a workaround? It's the only Automotive OS image currently available for ARM-based architectures in Android Studio.
During the first run of the emulator it works perfectly fine. However, as soon as the emulator is stopped and started again (cold boot or not) the following exception is thrown on each location request:
2023-01-02 15:17:59.431 1827-2496 FusedLocation com.google.android.gms.persistent E
dropping invalid locations [CONTEXT service_id=6 ]
vqy: location must not have realtime in the future
at vts.i(:com.google.android.gms@220221082@22.02.21 (060408-428111784):34)
at vrd.j(:com.google.android.gms@220221082@22.02.21 (060408-428111784):0)
at vrr.i(:com.google.android.gms@220221082@22.02.21 (060408-428111784):1)
at vrd.j(:com.google.android.gms@220221082@22.02.21 (060408-428111784):0)
at vrl.a(:com.google.android.gms@220221082@22.02.21 (060408-428111784):3)
at arsp.d(:com.google.android.gms@220221082@22.02.21 (060408-428111784):10)
at arvk.i(:com.google.android.gms@220221082@22.02.21 (060408-428111784):18)
at arve.a(:com.google.android.gms@220221082@22.02.21 (060408-428111784):0)
at vhn.onLocationChanged(:com.google.android.gms@220221082@22.02.21 (060408-428111784):0)
at android.location.LocationListener.onLocationChanged(LocationListener.java:63)
at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3180)
at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3177)
at com.android.internal.listeners.ListenerExecutor.lambda$executeSafely$0(ListenerExecutor.java:127)
at com.android.internal.listeners.ListenerExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Since "location must not have realtime in the future" seems to suggest a timing problem, I played around with setting the system time manually and cold booting the emulator each time, but had no success.
I request the location periodically with high accuracy like this:
val locationCallback = object : LocationCallback() {
override fun onLocationResult(result: LocationResult) {
Log.d("GoogleLocationApi", "onLocationResult: ${result.locations}")
}
}
val locationRequest = LocationRequest.Builder(2000)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setMinUpdateIntervalMillis(1000)
.build()
val fusedLocationClient: FusedLocationProviderClient =
LocationServices.getFusedLocationProviderClient(context)
fusedLocationClient.requestLocationUpdates(
locationRequest,
locationCallback,
Looper.getMainLooper()
)