64

I am working on google maps and I am getting this error. I had done the following things:

  1. Got My sha1 fingerprint.

  2. Registered my project and got my project key.

I don't know to how to get Google Maps Android API v2 enable because all the links I have tried are old and Google had changed it's site design. Please help me. I already have wasted a lot of time on this.

My Logcat:

enter image description here

Authorization failure.  Please see developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API: In the Google Developer Console (console.developers.google.com)


 Ensure that the "Google Maps Android API v2" is enabled.
 Ensure that the following Android Key exists:
   API Key: AIzaSyBK8rKr9lCRLhzv68I4Q26G9pHHO******
nimi0112
  • 2,065
  • 1
  • 18
  • 32

16 Answers16

81

From error it is clear that You did not enable google map api for android. To enable,

  1. Login google developer console
  2. Select Library option from left side panel.
  3. Now you can see all API list and go to Google Maps APIs and select Google Maps Android API .
  4. Now you can see option to enable/disable API. Enable it.

I hope it help you.

Avi Turner
  • 10,234
  • 7
  • 48
  • 75
USKMobility
  • 5,721
  • 2
  • 27
  • 34
35

Actually I had the same problem as well. my application runs and the map is blank!

First of all check whether you have installed Google Play in you android mobile.

actually I had the problem in API Key restrictions


Google Developer Console

  1. Login to Developer Console.
  2. In your Dashboard Navigation Menu.(left side)
  3. Select API & Services > Credentials.
  4. So you will be redirected to Credentials page were you can view all the API keys that you created (https://console.cloud.google.com/apis/credentials)
  5. Identify your Project API key and click on Edit Api Key.
  6. Under that you can see the Key restrictions
  7. From there remove all Application restrictions and Api restriction.

On your Android Mobile

  1. Uninstall the App.

Android Studio

  1. Build > Clean Project.
  2. Build > Rebuild Project.
  3. Run IT

This steps worked for me perfectly.

tronman
  • 9,862
  • 10
  • 46
  • 61
Ahamed Rasheed
  • 751
  • 9
  • 10
11

I had the same problem, but in the following setup:

My actual developing took place on a Windows machine. Then I bought a Mac and figured I'd develop on it. I installed Android Studio on my Mac, checked out my project from Github, then attempted a run of it using my Android phone. The APK installation carried out seamlessly. However, once the application launched on the phone, the GoogleMap wouldn't display, even though the rest of my app was functioning normally. Then I found this link => https://github.com/react-community/react-native-maps/issues/69, went to my console.developers.google.com/ and opened my Google Maps key that I had issue with.

What I saw was that the key was restricted to Android apps. But I was working on an Android app, how could this be the issue? Anyhow, I switched Key Restriction to None, reran my app, and GoogleMap loaded just as it should had.

felixy
  • 179
  • 1
  • 6
  • Interesting. I wonder then if they see it as an Apple device because it's debugging on one? – DBIT Mar 19 '19 at 15:41
  • No idea :) It feels like a century has passed since the last time I took a look into the google dev console. – felixy Mar 20 '19 at 08:43
  • Not a good idea to remove the restrictions. You need to generate a [new key](https://stackoverflow.com/a/53114208/1820553) SHA-1 fingerprint. Once generated and uploaded to the console, even the installed versions will work immediately. – kelalaka Mar 03 '20 at 10:58
6

you may need to add new SHA-1 Certificate fingerprints to your API key application restrictions page: enter image description here

to generate a SHA1 Certificate fingerprints for your debug build, use keytool of java jre as the following example command:

C:\Program Files\Android\Android Studio\jre\bin>keytool -list -v -keystore C:\Users\linhd\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
Linh Dao
  • 1,305
  • 1
  • 19
  • 31
3
  • Make sure Maps SDK for Android is enabled in API console.

  • Also you might need to add your package name and SHA-1 signing-certificate fingerprint to restrict usage for your key to be fully enabled.

enter image description here

Mitch
  • 576
  • 5
  • 11
  • This is the right answer, we need to enable Maps SDK for android in developer console. Then onle the map will be available. – Parthan_akon Nov 07 '20 at 07:56
2

This may happen when the package name is incorrect in the console credential section for development and production make sure your package name is correct. In my case, the package name was wrong when I corrected it map become visible

MarGin
  • 2,078
  • 1
  • 17
  • 28
1

I added a key from another test project to a main. Then I opened https://console.developers.google.com/ and added that key with a new application name (like Linh Dao wrote), but it didn't help.

Then I added a new activity (a template "Google Maps Activity" in a gallery) and opened a file google_maps_api.xml. From there I again found a link like https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=06:F2:F4:CD...applicationName.

I opened app/build.gradle, found applicationId value with applicationIdSuffix, if exists, and joined, for instance into com.example.myapp.debug. In the link I changed an applicationName to this new value and opened the link.

Again created a new project, generated a new key and edited it, wrote package name and SHA-1 fingerprint, like @Linh Dao wrote. Then saved. If you later with to find that key, find your project in Google console and open credentials.

I deleted an unnecessary map activity and in AndroidManifest retained

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

in application tag.

UPDATE

After several months I got the same exception in debug build. As I understood, I set wrong API key.

In LogCat I saw this exception:

enter image description here

Then I opened https://console.developers.google.com/, a needed project was opened, clicked on "Maps SDK for Android".

enter image description here

Turn to "Credentials" tab (you can also see https://developers.google.com/maps/documentation/android-sdk/signup for information). Click your API Key.

enter image description here

On the API key page, under Key restrictions, set the Application restrictions. Click + Add package name and fingerprint.

Enter your package name from LogCat above (for example, com.your_package.debug). Enter your fingerprint from LogCat (91:D6:...:F7). Save it.

As @Ahamed Rasheed wrote, I invalidated caches, cleaned and rebuilt the project.

CoolMind
  • 26,736
  • 15
  • 188
  • 224
1

Another reason can be that the relative path of secure.properties in the build.gradle is wrong. Check it just in case.

Aratz Manterola Lasa
  • 1,294
  • 1
  • 9
  • 4
1

I think you added the SHA-1 key of the release version to the Console.

When testing, you check the debug view.

SHA-1 keys differ in Release and Debug versions.

1

This usually happens on release version when you store the Google Maps API key for debugging only.

  1. When you add google maps API chances you stored it in res/values/google_maps_api(debug). Note the word debug, this means it only works for debug not release.
  2. You will have to SET the API key to res/values/strings or directly in the manifest metadata or Gradle as you preferred.
  3. Make sure the manifest meta-data is referencing to the one you change not the one in res/values/google_maps_api(debug)

For security, purpose don't forget to restrict your API https://developers.google.com/maps/api-security-best-practices

Aman
  • 2,316
  • 3
  • 17
  • 23
1

One click solution: Android Studio > Build > Clean Project.

Madis Männi
  • 168
  • 1
  • 5
0

In Android Error show its self mistake.

In Your Error Its show error to check first V2 google map API is ON in google developer Console.

just open google developer console and you just have to on this API and some configuration need have to do there for access map.

you can see process and more details from here.

Working With V2 Google Map

Vishal Thakkar
  • 2,117
  • 2
  • 16
  • 33
0

For anyone else that sees this as I did even though everything was setup, ensure you are in the correct project. These have to be done per project.

Micah Montoya
  • 757
  • 1
  • 8
  • 24
0

I encountered this problem when I opened my project with Android Studio on a different computer. Updating SHA-1 solved the problem.

Linux/MacOS

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

Windows

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Arda Kazancı
  • 8,341
  • 4
  • 28
  • 50
0

I faced the similar issues and I resolved the issues following the steps below:

1.Go to the Google Maps Platform > Credentials page. 2.Create a new API key 3. Under Key restrictions, set the following restrictions: Application restrictions: Select Android apps. Click + Add package name and fingerprint. Enter your package name and SHA-1 certificate fingerprint. For example:

com.example.android.mapexample

SHA-1 certificate fingerprint * : Use from the Error Message got from the Logcat Example:BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75

API restrictions:

Click Restrict key. Select Maps SDK for Android from Select APIs dropdown. If the Maps SDK for Android is not listed, you need to enable it. To finalize your changes, click Save.

Clean the Project and Run.

Ramya Bm
  • 27
  • 2
0

I have same kind of issue following thing i have done

-if any restriction there click radio button to "none" save changes

rebuild flutter project or app

Mr.pk
  • 1
  • 1