谷歌地图Api v2 Xamarin空白屏幕

时间:2013-07-08 21:26:01

标签: android xamarin google-maps-android-api-2

我无法让google maps api v2在我的Android Xamarin应用程序中显示任何空白屏幕。

在logcat中,我收到以下错误。

07-08 16:08:12.192: E/Google Maps Android API(28625): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

这让我相信这是我的API密钥的问题。我不知道我错过了什么。这是我的AndroidManifest.xml。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="2" android:versionName="2.0.0.0" package="com.deg.blubcnmobl.droid">
    <uses-sdk android:targetSdkVersion="12" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <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_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
    <uses-permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE" />
    <application android:icon="@drawable/logo" android:debuggable="true" android:enabled="true" android:persistent="false" android:allowClearUserData="true" android:theme="@android:style/Theme.Black.NoTitleBar">
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_KEY" />
    </application>
</manifest>

这是我的活动axml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
    class="com.google.android.gms.maps.SupportMapFragment"
    android:id="@+id/mapfragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</LinearLayout>

我在API设置中启用了Google Maps Api V2 Android。

Imgur

以下是我创建API密钥的页面。

Imgur

4 个答案:

答案 0 :(得分:3)

确保将这些权限添加到清单

<permission
    android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE"/>

答案 1 :(得分:0)

您似乎在清单中遗漏了许多权限。

  • 能够在API级别8及更高级别上运行的Maps V2示例清单

https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/AndroidManifest.xml

  • 能够在API级别8及更高级别上运行的Maps V2的示例布局

https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/res/layout/activity_main.xml

  • 能够在API级别8及更高级别上运行的Maps V2的示例活动

https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/src/com/example/googlemaps/v2/skeleton/api8/MainActivity.java

您可以克隆上面的git存储库并尝试完整的GoogleMapsV2SkeletonV8应用程序。

答案 2 :(得分:0)

请查看这篇文章:Google Map Android Api V2 Sample Code not working,如果你完全确定你做了正确的步骤并仍然看到空白屏幕然后按照第二个答案,身份验证被缓存到某处,尝试手动卸载应用程序(只是就像你使用普通应用程序一样)然后再次“运行”项目。

答案 3 :(得分:0)