1

I have Android M set up for my project and could build fine. However, When i launch the app, i see the following error and app doesn't launch:

<06-23 11:53:24.833 32416 32416 W System.err: java.lang.RuntimeException: **Unable to create application xxxxx: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.**
06-23 11:53:24.833 32416 32416 W System.err:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4697)
06-23 11:53:24.833 32416 32416 W System.err:    at android.app.ActivityThread.-wrap1(ActivityThread.java)
06-23 11:53:24.833 32416 32416 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1404)
06-23 11:53:24.833 32416 32416 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
06-23 11:53:24.833 32416 32416 W System.err:    at android.os.Looper.loop(Looper.java:148)
06-23 11:53:24.833 32416 32416 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:5401)
06-23 11:53:24.833 32416 32416 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
06-23 11:53:24.833 32416 32416 W System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:725)
06-23 11:53:24.833 32416 32416 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615)
06-23 11:53:24.833 32416 32416 W System.err: Caused by: **java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission**.
06-23 11:53:24.833 32416 32416 W System.err:    at android.os.Parcel.readException(Parcel.java:1599)
06-23 11:53:24.833 32416 32416 W System.err:    at android.os.Parcel.readException(Parcel.java:1552)
06-23 11:53:24.833 32416 32416 W System.err:    at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:598)
06-23 11:53:24.834 32416 32416 W System.err:    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:880)
06-23 11:53:24.834 32416 32416 W System.err:    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)

I have provided all these permissions access_fine_location, network_state, internet and access_coarse_location in my manifest file as "PROTECTED_NORMAL" So that they are available at install time.

I also noticed that Google API's were missing from Android M preview and may be thats causing the issue?? not sure though. Wondering if anyone came across the same issue and a possible solution?

part of manifest file:

 <uses-sdk
   android:minSdkVersion ="MNC"
    android:targetSdkVersion ="MNC" />

 <permission
    android:name="android.permission.ACCESS_NETWORK_STATE"
    android:protectionLevel="normal" />

 <permission
    android:name="android.permission.ACCESS_FINE_LOCATION"
    android:protectionLevel="normal" />

 <permission
    android:name="android.permission.ACCESS_COARSE_LOCATION"
    android:protectionLevel="normal" />

 <permission
    android:name="android.permission.INTERNET"
    android:protectionLevel="normal" />

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

<application>
 <uses-library android:name="com.google.android.maps" />
 **activity declarations**
</application>

Thanks!!

praveen_85
  • 182
  • 2
  • 13

1 Answers1

2

I have provided all these permissions access_fine_location, network_state, internet and access_coarse_location in my manifest file as "PROTECTED_NORMAL" So that they are available at install time.

No. Those permissions are defined by the platform, not you. You cannot redefine them to have lower protection levels, and the LOCATION permissions are dangerous. And, as the M Developer Preview documentation states, those are permissions that you need to request at runtime.

a possible solution?

Request the location permissions from the user before attempting to use the map. Note that I have not tried maps on the M Developer Preview yet, so it may be that this is not supported at all right now.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for your quick response @CommonsWare.. I am trying to access maps (to get location etc...) in my application class and hence needed to give location/maps permission at the time of installation. So did some tinkering with the permission levels which i now understand is not right. Google doc says "use PROTECTION_SIGNATURE or have the app as part of the system image" to grant permissions at install time. I tried signature and it wasn't working. I cannot have it as a system image. – praveen_85 Jun 25 '15 at 00:55
  • @praveen_85: AFAIK, there is no way to get location permissions at install time on M. – CommonsWare Jun 25 '15 at 00:58