Google Maps Android API: Authorization failure. Ensure that the “Google Maps Android API v2” is enabled. Ensure that the following Android Key exists

大兔子大兔子 提交于 2019-12-06 13:33:41

Hey I had the same problem today!,I solved it very easy for first you have to go https://console.developers.google.com and enable the android SDK maps and then create the api key, return in xamarin go to your manifest and add the google maps api key

https://docs.microsoft.com/it-it/xamarin/android/platform/maps-and-location/maps/obtaining-a-google-maps-api-key?tabs=windows

This is the documentation (I typed this fast because am on mobile now sorry)

follow to below link for generate google api key:- https://developers.google.com/maps/documentation/android-sdk/map-with-marker

Android Code Reference Link:-

https://www.zoftino.com/android-mapview-tutorial

I followed this tutorial and I was able to fix it: https://www.youtube.com/watch?v=sJBlQv6IptQ. The video makes references to this tutorial: http://ramsandroid4all.blogspot.com/2016/01/google-maps-android-example-in-android.html.

In my case, what I did was to create a new project at https://console.developers.google.com/. I used Android apps for Application restrictions:

For the Restrict usage to your Android apps section, I had to provide a Package name and a SHA-1 certificate fingerprint. The Package name was in my app/build.gradle, specifically here:

applicationId "[my package name]"

The SHA-1 certificate fingerprint I found it from Android Studio by running signingReport:

The result included something like this:

Alias: AndroidDebugKey
MD5: [The value]
SHA1: [The value]
SHA-256: [The value]
Valid until: Wednesday, May 5, 2049
----------

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
16:31:44: Task execution finished 'signingReport'.

Now the map works correctly in my Android app:

UPDATE 1: To my surprise, the maps were working correctly only on the Android Studio Emulator but not on real Android physical devices. The solution was what I posted at https://stackoverflow.com/a/56307654/4242086.

I got the exact same symptoms when I moved the project to a new computer. My solution was to generate a new key based on the error message. The google_maps_api.xml file had an URL in a comment to generate key but that is a static thing, so after moving the project to a new computer I rewrote the URL to match the error message's version.

https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=[put-the-thing-here]

Generated the key, put it in the XML file and it worked well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!