【发布时间】:2018-11-15 09:36:01
【问题描述】:
我正在开发一个包含 Google Maps API 的 Android 应用程序。为此,我从 console developers 启用了这个 API
Maps SDK for Android
我创建了一个凭据,我为 App Android 设置了一个限制,我还添加了应用程序包和指纹,并且在 API 限制选项卡上,我选择了 Maps SDK for Android。
之后,在我的应用程序清单中,我为谷歌地图编写了密钥。当我从 Android Studio 构建应用程序时,一切都很好(我的手机,一加 6,插在电脑上)。地图按我的意愿工作。但是,如果我尝试安装生成的 APK(来自构建的签名 APK -> 生成签名包/APK),则地图不会显示,并且我在 logcat 上收到错误
2018-11-15 10:19:45.590 13249-13249/? I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221
2018-11-15 10:19:45.590 13249-13249/? I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 221
2018-11-15 10:19:45.652 13249-13249/? I/Google Maps Android API: Google Play services client version: 12451000
2018-11-15 10:19:45.655 13249-13249/? I/Google Maps Android API: Google Play services package version: 14367037
2018-11-15 10:19:45.985 633-13359/? I/netd: ;; res_nquery(maps.googleapis.com, 1, 1)
2018-11-15 10:19:46.162 13249-13358/? W/System.err: com.google.maps.errors.RequestDeniedException: This IP, site or mobile application is not authorized to use this API key. Request received from IP address *********, with empty referer
2018-11-15 10:19:46.162 13249-13358/? W/System.err: at com.google.maps.DirectionsApi$Response.getError(DirectionsApi.java:90)
2018-11-15 10:19:46.162 13249-13358/? W/System.err: at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:289)
2018-11-15 10:19:46.162 13249-13358/? W/System.err: at com.google.maps.internal.OkHttpPendingResult.onResponse(OkHttpPendingResult.java:207)
2018-11-15 10:19:46.250 13249-13356/? E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
2018-11-15 10:19:46.251 13249-13356/? 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>): *********;************
我可以在这里看到 2 个问题:
This IP, site or mobile application is not authorized to use this API
和
Ensure that the "Google Maps Android API v2" is enabled
我真的不明白。其实,我想不通。我启用了一切,但仍然无法正常工作。还有其他事情要做吗?
【问题讨论】:
标签: java android api google-maps