4

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.

E_net4
  • 27,810
  • 13
  • 101
  • 139
BiGGZ
  • 503
  • 4
  • 17

4 Answers4

2

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.

Timo Ohr
  • 7,947
  • 2
  • 30
  • 20
  • Here is the link to get detail instruction https://developers.google.com/maps/documentation/android-api/signup – minhazur Apr 11 '18 at 18:05
2

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..." />
wibeasley
  • 5,000
  • 3
  • 34
  • 62
1
  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

Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
  • I've done all that sir. It works when im debugging, but when i make a release build, i just get a blank screen with the google logo at the bottom – BiGGZ Jan 19 '17 at 13:51
  • @BiGGZ , you have to add your release and debug keys into console. get SHA-1 like here http://stackoverflow.com/a/15727931/1979882 and put resultant key into console – Vyacheslav Jan 19 '17 at 13:54
  • I see. My SHA1 was different for debug and release. I made te changes now. Will let you know how it goes – BiGGZ Jan 19 '17 at 14:28
  • What goes? Two key have different sha1?or what? – Vyacheslav Jan 19 '17 at 14:31
  • Yes. My debug key had a different SHA1 than my release key. So now im making an API key using the release SHA1 and il let you know if that works – BiGGZ Jan 19 '17 at 14:41
  • Ok. But do not forget, you can use different sha1 for the same key. Just add several sha1 in the key preferences – Vyacheslav Jan 19 '17 at 14:53
1

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.

alexrnov
  • 2,346
  • 3
  • 18
  • 34
  • 3
    Hi Alex, when sharing content that is sourced from elsewhere, you need to include the source in the post itself; comments are temporal and no record is kept (publicly) of their contents or existence once they are deleted. Likewise, when copying content wholesale, it is strongly encouraged from an *ethical* standpoint to mark the answer as Community Wiki so that there is no potential accusation of stealing content for reputation's sake. – TylerH Sep 29 '20 at 18:39