mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Location updates incompatible with Play Services Location v21

Open jiurchuk opened this issue 3 years ago • 1 comments

Environment

  • Android OS version: 8.0
  • Devices affected: Samsung Galaxy J7
  • Maps SDK Version: 10.8.1
  • Play Services Location: 21.0.0 (com.google.android.gms:play-services-location:21.0.0)

Observed behavior and steps to reproduce

Display a view with the Map and add the ability to receive Location Updates via the Fused Location Provider.

Expected behavior

Receive location updates.

Notes / preliminary analysis

Version 21.0.0 included a change which makes Mapbox incompatible with it. I switched back to version 20.0.0 and everything works flawlessly.

Error stacktrace

FATAL EXCEPTION: main
Process: com.fauno.android.app, PID: 5386
java.lang.IncompatibleClassChangeError: The method 'com.google.android.gms.tasks.Task com.google.android.gms.location.FusedLocationProviderClient.requestLocationUpdates(com.google.android.gms.location.LocationRequest, com.google.android.gms.location.LocationCallback, android.os.Looper)' was expected to be of type virtual but instead was found to be of type interface (declaration of 'com.mapbox.android.core.location.GoogleLocationEngineImpl' appears in /data/app/com.fauno.android.app-ytL-iJQVqITXVMY4jl5lnQ==/base.apk:classes18.dex)
    at com.mapbox.android.core.location.GoogleLocationEngineImpl.requestLocationUpdates(GoogleLocationEngineImpl.java:58)
    at com.mapbox.android.core.location.GoogleLocationEngineImpl.requestLocationUpdates(GoogleLocationEngineImpl.java:26)
    at com.mapbox.android.core.location.LocationEngineProxy.requestLocationUpdates(LocationEngineProxy.java:34)
    at com.mapbox.maps.plugin.locationcomponent.DefaultLocationProvider.requestLocationUpdates(DefaultLocationProvider.kt:60)
    at com.mapbox.maps.plugin.locationcomponent.DefaultLocationProvider.requestLocationUpdates$lambda-2(DefaultLocationProvider.kt:66)
    at com.mapbox.maps.plugin.locationcomponent.DefaultLocationProvider.$r8$lambda$POSidhOF8Oq6uBMwTE9O9Q6vAXo(Unknown Source:0)
    at com.mapbox.maps.plugin.locationcomponent.DefaultLocationProvider$$ExternalSyntheticLambda1.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6942)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Additional links and references

N/A

jiurchuk avatar Oct 16 '22 23:10 jiurchuk

Thanks for reporting this issue.

Indeed, Google Play Services has introduces a breaking change. See release notes here: https://developers.google.com/android/guides/releases#october_13_2022

As you already mentioned please keep using Google Play Services Location 20.0.0 for the time being.

jush avatar Oct 17 '22 06:10 jush

confirmed. it still works with mapbox 9.6.1 and play-services-location:20.0.0

djdance avatar Dec 15 '22 11:12 djdance

This issue has been resolved in v10.10.0.

It's now possible to use Google Play Services Location 20 or 21.

jush avatar Dec 16 '22 10:12 jush

@jush any chance you could point me to the PR that addressed this issue? I looked at the diff between 10.9.1 and 10.10.0 and nothing looked related. We are facing the same issue on another project and finding it hard to support both version 20 and 21 in our library, I was hoping to steal some ideas from you. Thanks!

clembou avatar Jan 11 '23 18:01 clembou

Unfortunately the change was done in one of our internal libraries.

We ended up using a tiny amount of reflection to call the methods regardless of being an interface or a class.

jush avatar Jan 11 '23 19:01 jush

@jush Any chance this fix could be added for mapbox-gl-native too?

andrasfecz avatar Mar 29 '23 20:03 andrasfecz