mapbox / mapbox-gl-native-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
218 stars 114 forks source link

Location tracking issues Android 12 #730

Open felixkrautschuk opened 2 years ago

felixkrautschuk commented 2 years ago

In our Android app, the location tracking is not working as expected and it seems that only Android 12 devices are affected. We are using Mapbox Android SDK 9.7.2 in our production app and we followed this guide to retrieve location updates and to update the location marker position: https://docs.mapbox.com/android/core/guides/#requesting-location-updates

This is our experience:

We do not have multiple devices with Android 12 for testing, only the Google Pixel 3a. But we have a second device with Android 11 and those problems do not occur there, so this device acts the same way as the Pixel 3a did when there was Android 11 running.

I tried running the latest Sample App using the Mapbox v9 sdk from https://github.com/mapbox/mapbox-gl-native-android/tree/main/MapboxGLAndroidSDKTestApp and the location is also not correctly updated there.

Screenshot_20220405-092119

One difference to our production app: the location puck is blue, indicating that the location updates are correctly received, but the puck still does not move and the Toast shows the exact same coordinates all the time while walking, going by car or tram.

Is there anything that I am missing? Is it a bug in the v9 sdk? I am thankful for ANY advice.

I know there is already v10 outside, but we have no time at the moment to migrate and according to the Readme of this repo, v9 should be still supported so I hope that I can get some help here.

felixkrautschuk commented 2 years ago

I just realized that the location gets updated correcly for one time, after switching to the Google Maps app, show the user location there and then switching back to our app. The puck is moving to the latest location then, but it is again not getting any further updates (until switching to Google Maps app again).

When adding the play-services-location library to build.gradle, the location tracking is working as expected on our Android 12 device.

implementation("com.google.android.gms:play-services-location:19.0.1")

The docs at https://docs.mapbox.com/android/maps/guides/user-location/#location-provider mention that, but to me it sounded optional.