Google Maps API V2 - always get authentication error

前端 未结 7 1518
心在旅途
心在旅途 2020-12-19 21:31

I found lots of questions regarding this - and I am almost ashamed to ask it myself.

But no matter how hard I try, I simple do not get the Maps API running

相关标签:
7条回答
  • 2020-12-19 22:07

    Assuming

    • you are trying this on a device that has access to Google Play Services
    • you have linked your project with the Google Play Services library
    • you have setup the necessary permissions like this:

    snippet from manifest:

    <!-- Specify the correct minSDK and targetSDK versions. -->
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    
    <!-- Google Maps related permissions -->
    <permission
        android:name="com.ecs.google.maps.v2.actionbarsherlock.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    
    <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
    
    <!-- Network connectivity permissions -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    
    <!-- Access Google based webservices -->
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    
    <!-- External storage for caching. -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    <!-- My Location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    <!-- Maps API needs OpenGL ES 2.0. -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    
    • you have setup the map key like this :

    enter image description here

    • you have put the meta-data tag inside the application tag

      <meta-data
          android:name="com.google.android.maps.v2.API_KEY"
          android:value="AIzaSyA_u1faIXRhx_Q7NafFbrhQJEerl6UUbPY" />
      
    • you made sure that you are building the APK with the correct keystore (corresponding to the one defined in the API console).

    • you removed and redeployed your application completely after checking / updating these steps you should be good to go.

    From my experience I was able to follow the instructions on Google Maps Android API v2 Getting started, but I do recall having to completely undeploy and redeploy the app again after playing around with the API keys / permissions.

    On what device are you running ?

    0 讨论(0)
提交回复
热议问题