expletive inserted Does cursing make you feel better?

Android MapView Permissions and Prerequisites

Apparently you need the:

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

in your manifest file. Wasted a day on that INTERNET one! I swear it was working yesterday without it, but today I was just getting a blank map grid.

Other gotchas about MapViews:

  1. In the manifest file, those <uses-permissions> elements should come before your <application> element
  2. In order to define a MapView in an XML layout file, you can’t use a <MapView> element. Instead, you must have a <com.google.android.maps.MapView/> element, and you need to have a android:apiKey attribute in there as well, with a valid android maps api key. Not intuitive.
  3. Activity.findViewById is a very useful function
  4. The only type of Activity that can show maps is a MapActivity

7 Comments

And don’t foreget: if you want to use a MapActivity in your code the following tag is needed in your Manifest.xml:

it belongs INSIDE the tag (right before closing it worked fine for me)

regards Frank

Posted by Frank Trollmann on 4 November 2008 @ 4am

(INSIDE the application tag that is )

Posted by Frank Trollmann on 4 November 2008 @ 4am

Thank you for this article! I was beating my head against the wall thinking my maps API key wasn’t working when the problem was that my permissions were inside my application element.

Posted by Matthew on 8 November 2008 @ 1pm

Thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you

Seriously, I wasted a whole stupid day on the same d*** thing. Stupid INTERNET permission. I mean it does make sense that it would be required, but why aren’t those more clearly documented!?

Posted by Kirk on 1 March 2009 @ 10am

Thank you very much,
It was really helpful ..but it seesmthat ther is no imp of the order of that “Uses permission”.it works welln if it is give before or after “application element’

Posted by Sojan p r on 30 July 2009 @ 11pm

A lot of of folks talk about this issue but you wrote down really true words.

Posted by quizbuimb on 2 January 2010 @ 9am

The permissions tags after the application element was the issue for me. Thanks for the specific mention.
Really useful, and helpful.

Posted by androiddeveloper on 11 May 2010 @ 8pm

Leave a Comment