How to set GoogleMaps with GMSServices provideAPIKey

I previously had react-native-maps working on Android & iOS.

After upgrading to v31 my app crashes on iOS production environment. On Android, I never get permissions for location.

When I use xCode to follow the stacktrace I see this error logged.

*** Terminating app due to uncaught exception 'GMSServicesException', reason: 'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use'

I Googled and found this

How can I provide the Api Keys like suggested in the StackOverflow answers?

GMSPlacesClient.provideAPIKey("Your key")
GMSServices.provideAPIKey("Your key")

I read the documents but don’t see how to set this for iOS.

Thanks in advance!

1 Like

We got the same problem. When we build standalone for ios and use react-native-maps for Google Maps, app crashes. Here is relevant issue: https://github.com/react-native-community/react-native-maps/issues/2593.
That is big problem for us, not sure how we can fix this.
@adamjnav could you take a look?

@syndicate I resolved this issue after debugging with XCode.
My guess is that in newer versions of Expo we need to set the GoogleApiKey in app.json

https://docs.expo.io/versions/latest/workflow/configuration#__next

It looks like this for me after I got it fixed

"ios": {
      ...
      "config": {
        "googleMapsApiKey":  "MyApiKey123",
      },
      ...
    },
4 Likes

Thank you very much! Looks like it will help. We had api key in app.json like this:

// app.json
{
  "expo": {...},
  "config": {
    "googleMaps": {
      "apiKey": "..."
    }
  }
}

Would be nice if Expo team mentions this in their SDK 31 upgrade guide.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.