Google Maps API Key Not Being Picked Up

Hi, all. I’m trying to build a standalone app using exp build:android. I’ve got the following app.json (trimmed for speed’s sake):

{
“expo”: {

“android”: {
“config”: {
“googleMaps”: {
“apiKey”: “[mystery key here]”
}
}
}
}

I have not published to Play Store yet. I’m still testing with adb install on a Genymotion emulator. When I attempt to hit Google Maps, here’s what I see in adb logcat:

06-22 03:33:46.246 7129 7129 I Google Maps Android API: Google Play services package version: 12685026
06-22 03:33:47.074 7129 7256 E Google Maps Android API: Authorization failure. Please see Maps SDK for Android Quickstart  |  Google Developers for how to correctly set up the map.
06-22 03:33:47.075 7129 7256 E Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
06-22 03:33:47.075 7129 7256 E Google Maps Android API: Ensure that the “Google Maps Android API v2” is enabled.
06-22 03:33:47.075 7129 7256 E Google Maps Android API: Ensure that the following Android Key exists:
06-22 03:33:47.075 7129 7256 E Google Maps Android API: API Key: AIzaSyCPyKmt6in3JwAsogYikNNjor8qgU9stRQ
06-22 03:33:47.075 7129 7256 E Google Maps Android API: Android Application (<cert_fingerprint>;<package_name>): [MYSTERY CERT AND NAME HERE]

That is very much not the API key I put in my app.json file or what I have on Google’s API console. I know app.json is being read, though, because my icon and splash screen shows up when I install and run the APK.

I’m pretty sure the key highlighted above is a default public key getting pulled in from somewhere. Am I doing something dumb, or is there something else going on here?

Hi! Have you followed all the instructions here MapView - Expo Documentation including exp fetch:android:hashes? Make sure to also rebuild the app as mentioned in step 12.

Yup. I also verified the fingerprint and app name being shown in adb logcat was right. The API is the only thing that’s odd. Here’s something I noticed in the exp build:android logs:

▼configuring builder
release channel: default
▼running gulp task
[21:07:00] Using gulpfile /src/exponent/tools-public/gulpfile.js
[21:07:00] Starting ‘android-shell-app’…
▼reading manifest
Using manifest: {“android”:{“package”:“com.chokesware.redalert”,“versionCode”:1},“icon”:“./images/red-alert-icon.png”,“iconUrl”:“https://d1wp6m56sqw74a.cloudfront.net/~assets/0474da2fee2a24082b31d974167e8ffa",“ios”:{“bundleIdentifier”:“com.chokesware.redalert”},“locales”:{},“name”:"Red Alert”,“sdkVersion”:“27.0.0”,“slug”:“red-alert”,“splash”:{“image”:“./images/splash.png”,“imageUrl”:“https://d1wp6m56sqw74a.cloudfront.net/~assets/eb51a2e28330019b21eff08e84600c7f",“resizeMode”:“cover”},“version”:“1.0.0”,“id”:“@rdhammond/red-alert”,“revisionId”:“1.0.0-r.Yn90daZZjV”,“publishedTime”:“2018-06-22T21:06:56.544Z”,“bundleUrl”:“https://d1wp6m56sqw74a.cloudfront.net/%40rdhammond%2Fred-alert%2F1.0.0%2Ff3e7f6f320f2bf2084cea7f18d618716-27.0.0-android.js”,“releaseChannel”:“default”,“hostUri”:"exp.host:443/@rdhammond/red-alert”}

It doesn’t look like my entire config setting is getting picked up, but everything else is.

Okay I have zero idea what’s different, but I reloaded a native app on Genymotion, and everything’s working fine now. I did bump the versionCode on the app.json, so maybe that knocked loose something that was cached? Anyway, it’s working now :slight_smile:

Thanks!

1 Like

Weird, glad it eventually worked for you!

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