2

I've followed the steps here and here to create a MapView in our teams project which we sync with svn. After following the steps, MapView was running smooth, but only on my laptop. My project members are always getting

02-06 13:27:37.327: E/Google Maps Android API(19490): Authorization failure.

when opening the MapView. So I deleted the old one and generated a new SHA1 fingerprint for a new Google API Key on another laptop with my Google Account with:

keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android -v

So now it's working on the other laptop where I generated the SHA1 fingerprint but when I try to run the project on my laptop I'm now getting the

02-06 13:29:51.280: E/Google Maps Android API(20262): Authorization failure.

Error.

We are not using proguard-project.txt, we tried different devices where google-play-services is installed and included /extras/google/google_play_services/libproject/google-play-services_lib as a library. We also tried to generate multiple API Keys but only one was working.

What are we doing wrong? Do we have to use different Google Accounts to create individual keys?

Community
  • 1
  • 1
lambda
  • 3,295
  • 1
  • 26
  • 32

2 Answers2

3

Quoting the Google API Console:

API requests are sent directly to Google from your clients' Android devices. Google verifies that each request originates from an Android application that matches one of the certificate SHA1 fingerprints and package names listed below. You can discover the SHA1 fingerprint of your developer certificate using the following command[...]

One SHA1 certificate fingerprint and package name (separated by a semicolon) per line.

Highlight here on one per line.

Screenshot of Google Maps API Key - Configure Android Key`

For each laptop where you build your app you have to generate an SHA1 fingerprint and add it in the API Console.

lambda
  • 3,295
  • 1
  • 26
  • 32
2

You have two options here.

  1. Add a separate line to the api key for each device you have.

  2. Extract the api key to a file (eg. map_key.xml) and reference this file from the AndroidManifest.xml.

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/google_maps_api_key_v2" />
    

    Add this file to your .gitignore - so now each project member can override with its own key.

balazsbalazs
  • 4,071
  • 1
  • 24
  • 29