我在让 Google map 在 Android 应用中投入生产时遇到了很大的麻烦。这是我目前得到的(底部只是广告)。
我遵循的关键步骤:
1) 我已确保我已获得正确的 SHA1 生产 key ,并已在 Google 控制台 API 以及应用程序内实现它(它们是 google 提供的 key )。我已经注册了两个 key - 一个用于调试,一个用于生产
2) 互联网、位置等工作正常
3) 该应用程序在 Debug模式下工作,但在通过 USB 签名并安装在设备上时无法工作。我已经三次检查了标志的 SHA 1 签名等。
4) MapsFragment 来自 Android Studio 中可用的模板。
在生产模式下,日志猫显示如下:
01-11 16:04:54.511 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-11 16:04:54.516 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: YOUR_KEY_HERE
Android Application (<cert_fingerprint>;<package_name>): <SHA1 Removed for this> ;com.mike.mapstest
这个错误显然表明我的身份验证有问题? 我做错了什么?
最佳答案
基于您的可调试版本构建的 logcat 输出:
01-11 16:04:54.511 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-11 16:04:54.516 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: YOUR_KEY_HERE
Android Application (<cert_fingerprint>;<package_name>): <SHA1 Removed for this> ;com.mike.mapstest
您似乎没有覆盖 list 中的 api key 占位符 YOUR_KEY_HERE
(或单独的 api key 文件,具体取决于您的配置)。用您的实际 key 替换该字符串,无论它位于何处,您应该一切顺利。
编辑:this tutorial ,如果它与您的配置匹配,则可能解释了为什么您只在发布版本中看到此内容:
Return to Android Studio and paste the API key into the YOUR_KEY_HERE section of the file:
Note that these steps have enabled Google Maps support for the debug version of the application package. The API key will also need to be added to the google_maps_api.xml file located in MapDemo -> app -> src -> release -> res -> values when the release version of the application is ready to be built.
关于android - Google Maps V2 无法使用正确的 key 进行生产,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27883587/