0

I have received the following runtime exception in the crash reporting section of Firebase:

java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.

As this answer states, the exception can be solved by requesting the permissions at runtime.

Yet, what actually bugs me is the fact that in my Manifest file I only request COARSE LOCATION permission, while FINE LOCATION is never there.

AndroidManifest.xml

    ... // other permissions
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    ... // no sign of fine location

Why would a missing permission throw such an exception?

Notes: This is the first time the app crashes since it has been launched. The crash took place on an ALLVIEW VivaH7 API 19 with Android 4.4.2. (no similar crashes on any other devices or API's yet)

Also, is COARSE LOCATION considered a dangerous permission as well as FINE LOCATION? Therefore, should I request permission for COARSE LOCATION at runtime?

Catalin Ghita
  • 794
  • 8
  • 26
  • You can't use the gps provider with only course location. If you're using gps, you must request ACCESS_FINE_LOCATION. If you don't need gps and can get by with only network location, then you can use ACCESS_COARSE_LOCATION. – Daniel Nugent Jan 02 '18 at 18:45
  • @DanielNugent I understand, I was somehow remembering them the other way round, therefore the fault. Thanks and sorry for the hassle. – Catalin Ghita Jan 02 '18 at 18:54

1 Answers1

1

ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION both are dangerous permission.

Either ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION is required when you are getting location from NetworkProvider.

While,

ACCESS_FINE_LOCATION is required when you are getting location from GpsProvider.

So if you are getting location from NetworkProvider as well as GpsProvider, you have to add ACCESS_FINE_LOCATION permission also in your AndroidManifest.xml,

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Aditya
  • 3,525
  • 1
  • 31
  • 38