2013-07-08 58 views
0

我無法讓谷歌地圖api v2在我的Android Xamarin應用程序中顯示比空白屏幕更多的東西。谷歌地圖Api v2 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 V2的Android API在設置中打開。

Imgur

這裏是我創建的API密鑰的頁面。

Imgur

+0

它的一個答案,你可以張貼的AndroidManifest.xml中的全部? – Emmanuel

+0

好的,我發佈了整個AndroidManifest.xml文件 –

回答

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"/> 
+0

謝謝,我錯過了這個權限。但是,添加後我仍然收到相同的錯誤。更新問題中的AndroidManifest.xml。 –

+0

我要選擇這個作爲答案。我確實需要這個權限才能使其正常工作。我實際上也在使用錯誤的API密鑰。 :( –

+0

很高興我能夠有所幫助... – Emmanuel

0

你似乎缺少您的清單多項權限。

  • 爲地圖樣品清單V2能夠在API級8上運行的和API級8上運行的向上

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

  • 爲地圖樣品佈局V2能夠向上

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

  • 的地圖樣活性V2能夠在API級別8上運行的向上

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

您可以克隆以上的Git倉庫,並嘗試完整的GoogleMapsV2SkeletonV8應用。

+0

這是一個Xamarin項目,不是原生的。但是,我已經將您的項目用作參考,謝謝。仍然沒有運氣。 –

0

請查看這篇文章:Google Map Android Api V2 Sample Code not working,如果你完全確定你做了正確的步驟,仍然可以看到然後黑屏跟隨第二個答案中,身份驗證會被緩存到某處,嘗試手動卸載應用程序(就像使用普通應用程序一樣),然後再次「運行」該項目。