Android:Google Maps Android API:授权失败

SMBiggs

当我的应用尝试使用Google Maps API时,一旦尝试访问Google Map API数据,我将收到以下logcat错误(向右滚动以查看好东西!):

02-02 15:39:35.329 23868-24511/com.somepackage.name 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.
02-02 15:39:35.339 23868-24511/com.somepackage.name E/Google Maps Android API: Ensure that the following correspond to what is in the API Console:
                                                                                            API Key: AI~~~~~~~~~~~~~~~~~~~~~~~~~~ZwmI​
                                                                                            Package Name: com.somepackage.name
                                                                                            Certificate Fingerprint: 50:~~~~~~~~~~~~~~~~~~~~:D5

这是带有指纹和API密钥的Google Developers Support Console的图像(是的,它们确实匹配!)。我还等待Google服务器更新(根据Dox的要求是5分钟;我已经等了几个小时)。

在此处输入图片说明

这是我项目的主要AndroidManifest.xml(为简洁起见进行了编辑):

<?xml version="1.0" encoding="utf-8"?>
...
<!--
 The following two permissions are not required to use
 Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
    ...
    <!--The key to use Google's map API -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIz~~~~~~~~~~~~~~~~~~~~~~~~~~~~wmI​"/>

    <activity
    ...
    </activity>
    ...
</application>

我拥有Google的高级支持帐户,但到目前为止无法与他们联系。有谁知道为什么我会遇到此授权失败?

SMBiggs

After many hours, I figured out the answer plus one very important gotcha!

Situation

I need to re-explain as details I didn't know where important are actually paramount.

I inherited this project, so its history was unknown. Originally the program used the free version of Google Maps, which worked fine. Since this is a large company, they went ahead and paid for the full premium subscription service. Programmers added the new libraries and made the few code modifications to use those libraries.

But they still used the original (free) authorization key. This caused Google's servers to continue to treat the data as if it were a free version.

No one noticed this because the free Goole Maps API only has issues after some number (2500?) of API calls in one day. Our traffic only recently became high enough for this to be an issue. (After the limit, Google API sends an error message instead of data.)

Consequently any changes I made seemed to have no effect. And changing the keys in the code caused the authentication errors (see in question).

Solution

I had to make a new authentication key using the new premium libraries and console. This changed the Google server which of course caused all versions of the app already in existence to cease functioning!

The new authentication key, placed in the manifest, gets recognized by the Google API and everything works, yay! But we still need to release a new version in the Google Store.

Gotcha #1

文档DID NOT WORK中列出的AndroidManifest.xml命令

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AI............................mI​"/>

这是实际可行的正确名称:

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AI............................mI​" />

陷阱#2

但是在测试时,我仍然遇到各种错误。为什么?因为android设备会维护身份验证密钥的缓存。清除数据(最好是卸载)会清除这些缓存。现在一切正常,是的。

寓意:与API密钥,认证,证书和打交道时什么相似,卸载每一次!:)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Maps Android API:授权失败

来自分类Dev

Android Maps API v2授权失败

来自分类Dev

Google Maps Android API v2

来自分类Dev

Google Maps API Android-NullPointerException-setBoundsInParent

来自分类Dev

在Google Maps API Android上绘画

来自分类Dev

Google Maps Android API v2

来自分类Dev

Google Maps Android API自动完成

来自分类Dev

Android替代iOS Google Maps API GMSGeometryOffset

来自分类Dev

Android Studio中的Google Maps API问题

来自分类Dev

需要授权我的 Android 应用程序使用 Google Maps API

来自分类Dev

Android Google Maps LocationClient

来自分类Dev

Android Google Maps图标

来自分类Dev

Android-Google Maps

来自分类Dev

适用于企业的Google Maps Mobile SDK与Google Maps Android API

来自分类Dev

在Google Maps Android API中使用Google Maps离线地图(缓存)

来自分类Dev

Google Maps API v3导航(例如适用于Android的Google Maps)

来自分类Dev

适用于企业的Google Maps Mobile SDK与Google Maps Android API

来自分类Dev

在Google Maps Android API中使用Google Maps离线地图(缓存)

来自分类Dev

在Android Studio中使用Gradle管理Google Maps API密钥

来自分类Dev

意外的命名空间“地图”-Android Google Maps API

来自分类Dev

带有标记的Google Maps Android API问题

来自分类Dev

如何知道Android设备是否在地址附近Google Maps API

来自分类Dev

Android Google Maps Api V2崩溃

来自分类Dev

Google Maps Android API v2停止工作

来自分类Dev

Android Studio集成了Google Maps API v2

来自分类Dev

仅运行Google Maps Android API v2 3

来自分类Dev

从Android中的Google Maps DistanceMatrix API解析JSON

来自分类Dev

放大时,Android Google Maps Api不会解散

来自分类Dev

Android Google Maps API v2检查土地或水域

Related 相关文章

热门标签

归档