2014-01-30 78 views
0

加载谷歌地图的Android API V2,当我得到这个下面的错误无法加载地图使用谷歌地图的Android API V2

1. Authorization failure. 
2. Ensure that the following correspond to what is in the API Console: Package Name: com.example, API Key: AIzaSyDjm0K-ucpO5mDCPPnQ4CzVpdguqM714uo, Certificate Fingerprint: D9595FF0F329A6BBAC466C63284F83D17859894B 
3. Failed to contact Google servers. Another attempt will be made when connectivity is established. 
4. Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors). 
5. Failed to find provider info for com.google.android.gsf.gservices 

这里是我的源代码:

我AndroidManifest源代码

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.example"> 
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" /> 

    <application android:label="map" android:icon="@drawable/Icon"> 
     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 
     <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyDjm0K-ucpO5mDCPPnQ4CzVpdguqM714uo" /> 
    </application> 

    <permission android:name="com.example.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> 

    <uses-permission android:name="com.example.permission.MAPS_RECEIVE" /> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 

    <uses-feature android:glEsVersion="0x00020000" android:required="true" /> 

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.READ_GSERVICES" /> 
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
</manifest> 

我Main.axml源代码

Main.axml

<?xml version="1.0" encoding="utf-8"?> 
    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    class="com.google.android.gms.maps.MapFragment" /> 

我的活性1源代码

Activity1.cs

using System; 

using Android.App; 
using Android.Content; 
using Android.Runtime; 
using Android.Views; 
using Android.Widget; 
using Android.OS; 

namespace map 
{ 
    [Activity(Label = "map", MainLauncher = true, Icon = "@drawable/icon")] 
    public class Activity1 : Activity 
    { 
     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 

      SetContentView(Resource.Layout.Main); 
     } 
    } 
} 

顺便说一句,我使用API​​ Level 15模拟器。

这是我的API密钥

enter image description here

+0

为什么标记为C#? – Raghunandan

+0

错误信息在哪里? – Jagan

+0

发布错误消息以及您的布局,我们可以帮助您解决这个问题。 – Fllo

回答

-1

我找到了答案,我的问题。我的SHA1指纹不符合我使用的证书指纹(在我的错误消息中)。现在我的应用程序正确加载Android谷歌地图。

+1

您是如何验证SHA1指纹不匹配的? – Nav

0

编写以下功能将menifest

<uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true" /> 
+0

它已经在那里......;) – Fllo

+1

好.. :) 请问你能分享你的错误信息... – Namy

+0

检查您是否为Android启用了正确的Google地图API服务,即Google Maps Android API v2。 – Namy

0

提高XML

<fragment 
      android:id="@+id/map" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      class="com.google.android.gms.maps.**SupportMapFragment**" /> 
+0

我的目标是API Level 15以上,SupportMapFragment在这里不起作用。 – fulgen

+0

好吧,然后做一个新的谷歌控制台nd试试吧。 我觉得这是你的关键 – Namy

+0

链接创建API密钥的问题..: https://developers.google.com/maps/documentation/android/start?hl=zh-CN 你也可以从你的日食带你到SHAI – Namy

1

虽然不推荐,它是p可以设置模拟器来支持Android Maps API v2。仿真器必须配置为定位Google API API 17(Android 4.2.2)或更高版本的
你的是设置为API等级15 ...

另外你需要将项目的目标API和API最小级别设置为17(目前14)如果你想加载模拟器谷歌地图。

在这里阅读的先决条件: http://docs.xamarin.com/Guides/Android/Platform_Features/Maps_and_Location/Part_2_-_Maps_API/#Configuring_Maps_API_Prerequisites

+1

要添加到此,只支持最新API的AVD。因此,使用API​​等级17或18的AVD可能具有过时的Google Play服务版本,这可能不适合您的应用程序。 –

+0

我在调试中使用真实设备,但仍无法加载地图。它只显示带有Google徽标的白色屏幕并放大和缩小图标。 – fulgen