google maps api key not working v2 [英] google maps api key not working v2

查看:202
本文介绍了google maps api key not working v2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用谷歌地图的Android应用程序。
我已经遵循了这个机制,并使用调试键使应用程序在调试模式下工作。
我从这里找到的debug.keystore中检索到我的SHA-1密钥。


c:\Users\myself \.android\debug.keystore


使用


c:\Program Files\Java\jdk1.7.0_03\bin> keytool -list -v -keystore c:\debug.keystore


当我在测试手机上运行eclipse的应用程序(运行android 2.3.6),我使用系统调试时,地图显示正常。



但是,完成该应用程序后,在已发布的应用程序中,该地图未显示。可见的只有灰色的瓦片。



我知道这是API密钥的一个问题。



所以我创建了一个新的键(和一个apk),用它从谷歌的控制台生成一个新的API密钥。我删除了使用密钥生成的apk,因为它具有旧的ApiKey,并在这里粘贴了新的api密钥。

  < com.google.android.maps.MapView 
android:layout_width =fill_parent
android:layout_height =fill_parent
android:clickable =true
android: id =@ + id / mymap
android:apiKey =my_api_key

然后我重新出口我的项目,但是这次使用与之前创建的相同的键,因为它们包含相同的SHA-1。



然而,仍然是地图不显示,只有灰色的瓷砖出现。
我已经通过以下方式在api控制台中输入了SHA-1键。


18:3E:1D:8C :xx:xx:xx:xx:xx:xx:xx:xx:xx:x:xx:1D:E1:08:32:8E; com.mycompany.mapapp


我尝试恢复到我的调试键,但这次调试应用程序(从eclipse运行)也没有显示任何地图。



我的问题如下。


  1. 这是否仍然是正确的使用方法?因为在 - https://developers.google.com/maps/documentation/


  2. 我缺少什么?


  3. 这个方法是否被弃用或应该有效?



解决方案>

您正在为Google Maps V2生成ApiKey,但您正在使用v1 MapView com.google.android.maps.MapView
在Android Maps V2 API上,钥匙放在清单上,您使用 com.google.android.gms.maps.MapView 显示地图使用Google Play服务资料库。



我建议您阅读概述部分这里了解如何使用Google Play服务库设置项目,并查看新的API参考这里


I had an android application that utilizes google maps. I have followed the instuctions and made the app working in debug mode using the debug key. I have retrieved my SHA-1 key from the debug.keystore found here.

c:\Users\myself\.android\debug.keystore

using

c:\Program Files\Java\jdk1.7.0_03\bin>keytool -list -v -keystore c:\debug.keystore

The map was showing fine whenever I used tethered debug by running the app from eclipse on my test phone (which ran android 2.3.6).

However, after finishing the app, in the published app the map did not show. What was visible were only grey tiles.

I know this is an issue with the API key.

So I created a new key, (and an apk with it) used it to generate a new API key from the google's console. I deleted the apk that was generated with the key, as it had the old ApiKey, and pasted the new api key here.

<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:id="@+id/mymap"
android:apiKey="my_api_key"

Then I re exported my project but this time used the same key that I had created the step before as they contained the same SHA-1.

However, still the map does not show and only grey tiles appear. I have entered my SHA-1 key in the api console in the following way.

18:3E:1D:8C:xx:xx:xx:xx:xx:xx:xx:xx:xx:x:xx:1D:E1:08:32:8E;com.mycompany.mapapp

I tried to revert back to my debug key, but this time the debug app (running from eclipse) also did not show any maps.

my questions are the following.

  1. Is this still the correct method to use? Because in the --https://developers.google.com/maps/documentation/android/start#obtaining_an_api_key -- google used different approach using fragments.

  2. What am I missing ?

  3. Is this method deprecated or should work ?

解决方案

You're generating an ApiKey for the Google Maps V2, but you are using the v1 MapView com.google.android.maps.MapView. On the Android Maps V2 API, the key is placed on the manifest, and you use com.google.android.gms.maps.MapView to show the map, using the Google Play Services Library.

I suggest reading the overview section here to learn how to setup your Project with the Google Play Services Library, and looking at the new API Reference here.

这篇关于google maps api key not working v2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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