React-native-mapbox-gl: [Android] Crash when no location permission

Created on 16 Nov 2017  Â·  12Comments  Â·  Source: nitaliano/react-native-mapbox-gl

If I do not have location permission allowed and I set map view showUserLocation to true, my app crashes.

I think this is bit rude functionality from the lib, mapbox should check permissions before trying to do something which needs them.

FATAL EXCEPTION: main
Process: com.my.app, PID: 7597
java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
    at android.os.Parcel.readException(Parcel.java:1620)
    at android.os.Parcel.readException(Parcel.java:1573)
    at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:606)
    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:880)
    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
    at com.mapzen.android.lost.internal.FusionEngine.enableGps(FusionEngine.java:98)
    at com.mapzen.android.lost.internal.FusionEngine.enable(FusionEngine.java:72)
    at com.mapzen.android.lost.internal.LocationEngine.setRequest(LocationEngine.java:36)
    at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.requestLocationUpdates(FusedLocationProviderApiImpl.java:50)
    at com.mapbox.services.android.location.LostLocationEngine.requestLocationUpdates(LostLocationEngine.java:123)
    at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.onConnected(RCTMGLMapView.java:598)
    at com.mapbox.services.android.location.LostLocationEngine.activate(LostLocationEngine.java:51)
    at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.enableLocationLayer(RCTMGLMapView.java:757)
    at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.onMapReady(RCTMGLMapView.java:249)
    at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onMapReady(MapView.java:946)
    at com.mapbox.mapboxsdk.maps.MapView$MapCallback.access$1000(MapView.java:911)
    at com.mapbox.mapboxsdk.maps.MapView$MapCallback$1.run(MapView.java:929)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Most helpful comment

Hello,
Yet to 6.0.1 released, but I got the same issue, actually it doesn't request any permission whatsoever, but the release apk crashes anyway with the same error, do I have to request somewhere else than the installation setting ?

AndroidManifest.xml :
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I also have the showUserLocation set to true

Do I miss something ?

Thanks in advance @nitaliano

All 12 comments

I'll get this into 6.0.1 and it will be published tomorrow.

Closing this out as it's in master now and 6.0.1 will be published today

Hello,
Yet to 6.0.1 released, but I got the same issue, actually it doesn't request any permission whatsoever, but the release apk crashes anyway with the same error, do I have to request somewhere else than the installation setting ?

AndroidManifest.xml :
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I also have the showUserLocation set to true

Do I miss something ?

Thanks in advance @nitaliano

Did you figure out whats the issue?
Still getting "gps" lcoation provider requires ACCESS_FINE_LOCATION permission
though it is set in the AndroidManifest.xml

@roesneb @nitaliano unfortunately, the problem remains

@GuillotJessica i figured out what was the problem for me.
If you look in the example App.js there are two Android relevant parts.
Unfortunately i only did the first part in componentWillMount (requestAndroidLocationPermissions)
but actually forgot check in the render function for the isGranted state change.

I got this error when i want to show user location in maps. I tried every thing but nothing work. After many tries i got solution then i decided to share with all developers. If it works please subscribe and share this video. https://www.youtube.com/watch?v=_mi_QNmXSwM

@roesneb @nitaliano unfortunately, the problem remains

check this it will work
I got this error when i want to show user location in maps. I tried every thing but nothing work. After many tries i got solution then i decided to share with all developers. If it works please subscribe and share this video. https://www.youtube.com/watch?v=_mi_QNmXSwM

If I do not have location permission allowed and I set map view showUserLocation to true, my app crashes.

I think this is bit rude functionality from the lib, mapbox should check permissions before trying to do something which needs them.

FATAL EXCEPTION: main
Process: com.my.app, PID: 7597
java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
  at android.os.Parcel.readException(Parcel.java:1620)
  at android.os.Parcel.readException(Parcel.java:1573)
  at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:606)
  at android.location.LocationManager.requestLocationUpdates(LocationManager.java:880)
  at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
  at com.mapzen.android.lost.internal.FusionEngine.enableGps(FusionEngine.java:98)
  at com.mapzen.android.lost.internal.FusionEngine.enable(FusionEngine.java:72)
  at com.mapzen.android.lost.internal.LocationEngine.setRequest(LocationEngine.java:36)
  at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.requestLocationUpdates(FusedLocationProviderApiImpl.java:50)
  at com.mapbox.services.android.location.LostLocationEngine.requestLocationUpdates(LostLocationEngine.java:123)
  at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.onConnected(RCTMGLMapView.java:598)
  at com.mapbox.services.android.location.LostLocationEngine.activate(LostLocationEngine.java:51)
  at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.enableLocationLayer(RCTMGLMapView.java:757)
  at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.onMapReady(RCTMGLMapView.java:249)
  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onMapReady(MapView.java:946)
  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.access$1000(MapView.java:911)
  at com.mapbox.mapboxsdk.maps.MapView$MapCallback$1.run(MapView.java:929)
  at android.os.Handler.handleCallback(Handler.java:739)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:148)
  at android.app.ActivityThread.main(ActivityThread.java:5417)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I got this error when i want to show user location in maps. I tried every thing but nothing work. After many tries i got solution then i decided to share with all developers. If it works please subscribe and share this video. https://www.youtube.com/watch?v=_mi_QNmXSwM

@ahmedfaraz587 the video helps me to figure it out the problem, cheers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gp2mv3 picture Gp2mv3  Â·  3Comments

olofd picture olofd  Â·  3Comments

Amalp picture Amalp  Â·  3Comments

yaduc picture yaduc  Â·  3Comments

alexisohayon picture alexisohayon  Â·  4Comments