加载google map 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" />
我的Activity1源代码
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密钥
答案 0 :(得分:1)
虽然不推荐,但可以设置模拟器以支持Android Maps API v2。必须将模拟器配置为定位 Google API Level 17 (Android 4.2.2)或更高版本。
您的设置为 API Level 15 ...
如果您想在模拟器中加载Google地图,还需要将项目的目标API和最低API级别设置为17(当前为14)。
答案 1 :(得分:0)
将以下功能写入您的清单
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
答案 2 :(得分:0)
改善你的xml
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.**SupportMapFragment**" />
答案 3 :(得分:-1)
我找到了问题的答案。我的SHA1指纹与我使用的证书指纹不匹配(在我的错误消息中)。现在我的应用程序正确加载了android谷歌地图。