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.

[ANDROID] Mapbox.UserLocation crashes my app!

See original GitHub issue

Describe the bug I wanted to give a try to the latest release candidate (want to upgrade to the new Mapbox pricing model). My app uses the new <UserLocation /> inside a <MapView />. My app crashes on launch. It does not crash if I remove the <UserLocation />.

I added and removed the permissions and features and it still crashes.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-feature android:name="android.hardware.location.gps"/>

To Reproduce Create and render that component (simplified code):

function Map() {
  return (
    <MapView>
      <UserLocation />
    </MapView>
  )
}

Expected behavior I would expected my app to run properly.

Versions:

  • Platfrom: Android
  • Device: ONE A2005
  • OS: 3.6.1
  • SDK Version: 28
  • React Native Version: 0.59.9

Additional context

Here is the log: 07-10 15:09:37.634 30607 30649 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules 07-10 15:09:37.634 30607 30649 E AndroidRuntime: Process: com.avcan, PID: 30607 07-10 15:09:37.634 30607 30649 E AndroidRuntime: java.lang.SecurityException: “passive” location provider requires ACCESS_FINE_LOCATION permission. 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1620) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1573) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at android.location.ILocationManager$Stub$Proxy.getLastLocation(ILocationManager.java:738) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at android.location.LocationManager.getLastKnownLocation(LocationManager.java:1240) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.mapbox.android.core.location.AndroidLocationEngineImpl.getLastLocationFor(AndroidLocationEngineImpl.java:58) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.mapbox.android.core.location.MapboxFusedLocationEngineImpl.getBestLastLocation(MapboxFusedLocationEngineImpl.java:81) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.mapbox.android.core.location.MapboxFusedLocationEngineImpl.getLastLocation(MapboxFusedLocationEngineImpl.java:36) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.mapbox.android.core.location.LocationEngineProxy.getLastLocation(LocationEngineProxy.java:25) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.mapbox.rctmgl.location.LocationManager.getLastKnownLocation(LocationManager.java:125) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.mapbox.rctmgl.modules.RCTMGLLocationModule.getLastKnownLocation(RCTMGLLocationModule.java:88) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at android.os.Looper.loop(Looper.java:152) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232) 07-10 15:09:37.634 30607 30649 E AndroidRuntime: at java.lang.Thread.run(Thread.java:818)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
RichardLindhoutcommented, Aug 17, 2019

Some code snippets. Thanks @karlguillotte 😃

import { Platform } from 'react-native'
import Mapbox from '@react-native-mapbox-gl/maps'

export async function hasLocationPermission() {
  if (
    Platform.OS === 'web' ||
    Platform.OS === 'ios' ||
    (Platform.OS === 'android' && Platform.Version < 23)
  ) {
    return true
  }
  const isGranted = await Mapbox.requestAndroidLocationPermissions()

  console.log('isGranted', isGranted)
  return isGranted
}

const [permission, setPermission] = useState(false)
  useEffect(() => {
    const task = async () => {
      const per = await hasLocationPermission()
      setPermission(per)
    }
    task()
  }, [false])
2reactions
stale[bot]commented, Oct 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[ANDROID] Mapbox.UserLocation crashes my app! · Issue #233
My app uses the new <UserLocation /> inside a <MapView /> . My app crashes on launch. It does not crash if I...
Read more >
Mapbox app crashes when implementing a trailing line behind ...
The app can track the users current location on start up and also track any movement. When I add the code to add...
Read more >
User location | Maps SDK | Android - Mapbox docs
Learn how user location works in the Mapbox Maps SDK for Android. Cutomize the location engine and how user location is represented on...
Read more >
Build an Android App in Java - Mapbox - YouTube
"Our friends at Devslopes made an awesome video tutorial showing how to build an Android app with Mapbox Navigation SDK. In part #1...
Read more >
rnmapbox/Lobby - Gitter
I use "@react-native-mapbox-gl/maps": "^8.1.0-rc10". scenario: launch the application; application load and show map and user location ...
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