Search code examples
androidgoogle-mapsgoogle-maps-android-api-2android-mnc

Permission issue on MNC with Google Maps


I have created a minimal example that demos the problem in this question

https://github.com/dbachelder/MNCMapTest

I ran into this issue in a real app, but created this project to demo the minimal example.

The project was created with Android Studio 1.3.1

It was a "Google Maps Activity" project targeting MNC.

The only change I made was changing

compile 'com.android.support:appcompat-v7:23.+'

to

compile 'com.android.support:appcompat-v7:22.+'

as 23.+ doesn't seem to exist yet... (not sure why it's used by the project creation wizard)

On start up this exception is seen.

 Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        at com.google.maps.api.android.lib6.d.t.a(Unknown Source)
        at com.google.maps.api.android.lib6.d.ft.a(Unknown Source)
        at com.google.maps.api.android.lib6.d.aj.a(Unknown Source)
        at com.google.maps.api.android.lib6.d.ai.a(Unknown Source)
        at com.google.android.gms.maps.internal.x.onTransact(SourceFile:107)
        at android.os.Binder.transact(Binder.java:387)
        at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView(Unknown Source)
        at com.google.android.gms.maps.SupportMapFragment$zza.onCreateView(Unknown Source)
        at com.google.android.gms.dynamic.zza$4.zzb(Unknown Source)
        at com.google.android.gms.dynamic.zza.zza(Unknown Source)
        at com.google.android.gms.dynamic.zza.onCreateView(Unknown Source)
        at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:924)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1116)
        at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1218)
        at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2170)
        at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
        ... 19 more

as you can see in the manifest:

https://github.com/dbachelder/MNCMapTest/blob/master/app/src/main/AndroidManifest.xml

The permission in question is there.

The emulator is running the latest version of M.

Is there something I am missing to get maps to play nice in M? Like ask for the permission before I inflate the layout containing the map? Or am I just jumping the gun and I need to wait a bit longer for all of this to be ready for testing?

That seems like an annoying limitation to have to ask for the storage permission at startup for apps built around the map.

UPDATE: there is now a branch of the project that works.. here is the diff: https://github.com/dbachelder/MNCMapTest/pull/1/files


Solution

  • I have it on good authority that this will not be an issue by the time M is live. GPS will be updated to not require this permission for maps in the near future so the only time you will have to bother with this issue is in this interim phase.