Google Maps API key may be invalid for your bundle ID

19,917

Solution 1

I found that there is no difference for api key which surrounded with curly braces or not.

Please make sure "enable GoogleMap SDK for iOS"

You may also see reference

Solution 2

step by step

1.- go Google ApisConsole

2.- select Services and activate Google Maps SDK for iOS

3.- later select API Access and Create new iOS key with your bundle identifier example com.example.myProject

4.- copy Api key in your Project  [GMSServices provideAPIKey:@"kajshdklasjhdakls_LTcJWZqpRJ1BQmHxX9i0lI"]; on AppDelegate

goodluck

Solution 3

Here are two possible fixes:

Possible Fix 1

In the line,

[GMSServices provideAPIKey:@"{AIzaSyDCPXPLUkK3UVrLr9msaS6-EsZ6UHbVgEq}"];

the api key should be surrounded with curly braces.

Possible Fix 2

In the didFinishLaunchingWithOptions method in your AppDelegate, the above line should come before you instantiate your root view controller, not after.

Solution 4

Just my 2 cents; I enabled Google Maps for iOS in the services section of the API console after I had generated my API key which didn't work. I just deleted my key out and created a new one and hey presto (this was after a lot of testing, so it was definitely the issue, strangely).

Solution 5

use this code: NSLog(@"my bundle id is: %@", [[NSBundle mainBundle] bundleIdentifier]); for identify the bundle identifiers you need generated Api access in google apis.

for example: my Bundle identifier in my project x-code is projects.example.mymap, then you should copy and paste the same into apiaccess and generate this apikey.

if the problem persists, create other key and remove the last, use the new key in your app.

good luck!

Share:
19,917

Related videos on Youtube

lxcid
Author by

lxcid

Updated on September 26, 2022

Comments

  • lxcid
    lxcid over 1 year

    We have a Google API Key that have been working for the past few months but suddenly yesterday it stop working below is the error.

    2013-09-20 23:01:36.483 SampleApp[907:a0b] Google Maps SDK for iOS cannot connect or validate APIKey: Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x18828d90 {data=<CFData 0x14d04c30 [0x6174ec8]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}} 2013-09-20 23:01:36.484 SampleApp[907:a0b] Your key may be invalid for your bundle ID: com.company.SampleApp

    We were not able to find the account that own of the API key. Is there a way that we can Contact the Google Maps API team to request for help in identifying the account and help resolve the issue?

    • Jing
      Jing over 10 years
      Did you change the app bundle id in Xcode? Clearly the api key is bundled with your app bundle id to prevent api abuse. If you changed the app bundle id, then you cannot use the same api key. Check that, or just apply for a new api key using the current app bundle id.
    • Brett
      Brett over 10 years
      You can mail me with your API Key at [email protected]. I'm guessing com.company.SampleApp isn't your actual app bundle id...
    • mbpro
      mbpro over 10 years
      Were you able to solve this? I'm experiencing the same problem. I changed bundle name and then changed it back and even if I try to recreate app ID many times, I get the same message...
  • kakashy
    kakashy about 10 years
    I was the same problem, but I solved removing the curly braces.
  • chuckSaldana
    chuckSaldana about 10 years
    Also the api key IS NOT be surrounded with curly braces in my case [GMSServices provideAPIKey:@"api_key"]; and works fine now. Thanks.
  • R00We
    R00We about 10 years
    i forgot click on. Thanks
  • Brian Victor
    Brian Victor about 10 years
    To elaborate on this, "Enable Google Maps SDK for iOS" has to be enabled in Google's developer console. I was encountering this error when I had enabled the SDK for Android and forgot to do it for iOS as well.
  • Admin
    Admin over 9 years
    This was spot on. I got caught up in checking code and making sure the API key matched and forgot to enable the service! (facepalm)
  • MagnunStalin
    MagnunStalin over 6 years
    Thanks a lot, 3 days trying to fix it. Lol.
  • ssowri1
    ssowri1 about 6 years
    Thank you. It saved my time.
  • shahil
    shahil almost 4 years
    Thank you. This finally fixed my issue and now I can see the map loading.