BiGGZ
BiGGZ

Reputation: 503

Android google maps release key?

How do I get a release key for Google Maps? I used my current key with a debug.apk and a signed-release.apk, and the maps dont render on the release.apk, so I assume its a API key issue.

All the answers for this question on SO date back to 2013/14 and this page is completely silent on the issue.

Upvotes: 4

Views: 4988

Answers (4)

alexrnov
alexrnov

Reputation: 2534

From How to configure Google Maps API keys for Android by Dragana Vucic:

Go to Google API Console -> APIs & Services -> Credentials and click on Create Credentials -> API key. This option will generate a key that is not restricted to anything (yet).

  1. Copy this generated key and click close
  2. In Android Studio: Build -> Select Build Variant -> release
  3. Open file res/values/google_maps_api.xml(release) and paste generated key
  4. Publish app
  5. Go to https://play.google.com/console/developers and select your publich app
  6. Go to page: release management -> app signing
  7. copy SHA-1 certificate fingerprint
  8. Return to https://console.developers.google.com/apis/credentials
  9. Click on release key. In "Key restrictions" section to select "Android Apps"
  10. In "Restrict usage to your Android apps" section enter package name and SHA-1 from Google play console
  11. In "API restriction" section select -> Restrict key -> 1 API.
  12. Click Save

After these steps, the google map service will work for the published application.

Upvotes: 1

Anatoliy Kolesnik
Anatoliy Kolesnik

Reputation: 21

Just add string not from resources(@string/google_maps_key), but hardcode.

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIza..." />

Upvotes: 2

Timo Ohr
Timo Ohr

Reputation: 7947

The same way you get a "debug" key. There is no real difference, just as there is no real difference between a debug and a release certificate in Android (except that the debug certificate gets created automatically for you and resides in your Android settings folder).

Get the SHA-1 fingerprint for your Android release key and use it along with the proper package name (debug builds usually have a ".debug" attached, so make sure to omit that) to create a new Google Maps Key in the Google Developer Console.

Upvotes: 2

Vyacheslav
Vyacheslav

Reputation: 27221

  1. You have to enable Google Maps API here:

https://console.developers.google.com/apis/dashboard

  1. You have to create key here:

https://console.developers.google.com/apis/credentials/oauthclient?

  1. Put your key into AndroidManifest.xml file.

That's it!

More detailed:

https://developers.google.com/maps/documentation/android-api/config?hl=en

Upvotes: 1

Related Questions