Google Maps API V2 - 总是出现身份验证错误 [英] Google Maps API V2 - always get authentication error

查看:35
本文介绍了Google Maps API V2 - 总是出现身份验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了很多关于此的问题 - 我几乎羞于自己问这些问题.

I found lots of questions regarding this - and I am almost ashamed to ask it myself.

但无论我如何努力,我都认为根本无法运行 Maps API

But no matter how hard I try, I simple do not get the Maps API running at all!

不适用于演示项目 com.example.mapdemo,不适用于我自己的项目.

Not with the demo project, com.example.mapdemo, not with my own project.

我肯定已经为我的应用程序和 com.example 注册了我的 debug.keystore SHA1 指纹 - 我还尝试了浏览器 API 密钥,每个人都说这也可以.

I definitely have my debug.keystore SHA1 fingerprint registered, now for both my app and com.example - I also tried the browser API key where everybody says that would work, too.

但是没有.

我总是得到:

06-16 11:21:29.860: E/Google Maps Android API(2382): Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.

我对此非常非常生气.怎么可能不完整和彻底地描述这件事,以便那些能够编写 Android 应用程序的人能够遵循并取得成功?

I am getting REALLY, REALLY mad at this. How is it possible to NOT completely and thoroughly describe this matter so that people that are otherwise able to program Android apps, can follow and succeed??

怎么样?

谁能告诉我还有什么问题?

Could anybody please tell me what else could be wrong?

附加组件:我完全按照规范设置了所有内容,从我的 debug.keystore 中获取了我的密钥,使用 com.example 进行了地图演示,并使用了我自己的应用程序包.不起作用.另外:那个愚蠢的空窗口.这到底是怎么回事... :-(

Add-on: I set up everything exactly according to the specs, got my key from my debug.keystore, tried it with com.example for the maps demo, with my own package for my app. Does not work. Plus: that silly empty window. How on earth is that gonna work... :-(

推荐答案

假设

  • 您正在可以访问 Google Play 服务的设备上尝试此操作
  • 您已将您的项目与 Google Play 服务库相关联
  • 您已设置必要的权限,如下所示:

来自清单的片段:

<!-- Specify the correct minSDK and targetSDK versions. -->
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<!-- Google Maps related permissions -->
<permission
    android:name="com.ecs.google.maps.v2.actionbarsherlock.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />

<!-- Network connectivity permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<!-- Access Google based webservices -->
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

  • 您已经像这样设置了地图键:
    • 您已将元数据标签放在应用程序标签中

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

  • 您确保使用正确的密钥库(对应于 API 控制台中定义的密钥库)构建 APK.

  • you made sure that you are building the APK with the correct keystore (corresponding to the one defined in the API console).

    根据我的经验,我能够按照 Google Maps Android API v2 入门中的说明进行操作,但我确实记得在使用 API 密钥/权限后必须再次完全取消部署和重新部署应用.

    From my experience I was able to follow the instructions on Google Maps Android API v2 Getting started, but I do recall having to completely undeploy and redeploy the app again after playing around with the API keys / permissions.

    你在什么设备上运行?

    这篇关于Google Maps API V2 - 总是出现身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆