Cannot load Google maps

2019-09-08 15:15发布

问题:

One of the options in my app is launching the google maps.

The scenarios:

  • Regular install => adb install xx.apk -> maps are loading successfully.
  • Install it with test server -> calabash-android gen xx.apk, etc. -> the maps are not loading.

In the Android monitor I got the next message in the logcat:

05-14 18:43:18.239: E/Google Maps Android API(24417): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

Tried to change Keystores but I got the same results.

There is no issue with the network connection.

What I’m missing?

回答1:

When you get your Google Maps key, you need to get two. One for the debug version of your APK, and one for your release version of your APK.

https://developers.google.com/maps/documentation/android/start#display_your_apps_certificate_information

You need to get your signing key information (stored on your computer), and then register it with Google with their online console.

What's happening here is one of your APKS is built with your debug key, and one with your release key, but the map keys are the same with both of them.