question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UserLocation does not use high accuracy on Android 12

See original GitHub issue

Describe the bug
After users have upgraded to Android 12 the UserLocation component no longer appears to use high accuracy mode. This is indicated by the users location darting around (as opposed to being true to their actual location) and the location status icon is no longer shown. On Android 11 the location status icon was shown regardless.

Using React Native Geolocation with a watch and high accuracy mode turned on corrects to the expected behaviour showing an accurate location and the location status icon.

To Reproduce
Use a UserLocation component on any Android 12 device. I have been using a S20 FE and an S21 to confirm (Android 12 vs still on Android 11)

Example:

import React from 'react';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
  UserLocation,
} from '@rnmapbox/maps';

class BugReportExample extends React.Component {
  render() {
    return (
      <MapView style={{flex: 1}}>
        <UserLocation />
      </MapView>
    );
  }
}

Expected behavior
The users location is shown correctly and the location status icon is shown indicating use of high accuracy location.

Actual behavior
Users location darts around and no location status icon is shown.

Screenshots

Versions (please complete the following information):

  • Platform: Android
  • Platform OS: Android 12
  • Device: Android S20 FE
  • Emulator/ Simulator: no
  • Dev OS: MacOS 12.1
  • @rnmapbox/maps Version 8.4.0
  • Mapbox GL version 9.7.1
  • React Native Version 0.66.4

Additional context
N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RobertSasakcommented, Jun 1, 2022

Solution is described https://github.com/mapbox/mapbox-gl-native-android/issues/730 and https://docs.mapbox.com/android/maps/guides/user-location/#location-provider TLDR add following into build.gradle

implementation("com.google.android.gms:play-services-location:19.0.1")
0reactions
benjamin-sweneycommented, Jun 1, 2022

@RobertSasak I use the MapboxGL.requestAndroidLocationPermissions(); function on boot of my application to call the correct permissions. This includes both required permission calls as needed on Android 12.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage your Android device's location settings - Nexus Help
Open your phone's Settings app. ... Location. If you don't find "Security & Location," tap Location. Tap Mode. Select a mode: High accuracy:...
Read more >
Request location permissions - Android Developers
Overview · Know which packages are visible automatically · Declare package visibility needs · Fulfill common use cases · Test package visibility.
Read more >
Not able to get accurate location on android device
Some time user location is correct and within a 20-30 seconds we got some wrong location with accuracy say > 50 or 100....
Read more >
How to Turn On/Off Google Location Accuracy [Android 12]
Want to know How to Turn On/Off Google Location Accuracy on Android smartphone? This guide will show you how to do on Android...
Read more >
LocationRequest | Google Play services
For example, applications that are showing the user's location in realtime may consider a PRIORITY_HIGH_ACCURACY request with a short interval.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found