我正在開發MonoDroid項目,似乎無法解決此問題。我正嘗試使用MapsAndLocationDemo_v2項目,甚至無法將地圖加載到SimpleMapDemo項目中。我在這個問題上經歷了許多SO職位。Monodroid Google Maps API v2 - 聯繫Google服務器時出錯
地圖載入,但白色和應用程序輸出狀態:
[Google Maps Android API] Failed to contact Google servers. Another attempt will be made when connectivity is established.
[Google Maps Android API] Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
我建了谷歌在該項目README.md按照指示播放客戶服務庫。
我產生使用位於debug.keystore一個新的Android谷歌地圖V2 API密鑰:
C:\Users\[USERNAME]\AppData\Local\Xamarin\Mono for Android\debug.keystore
和更換項目的manifest.xml的一個如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="5" android:versionName="4.0" package="com.xamarin.docs.android.mapsandlocationdemo2">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
<!-- Google Maps for Android v2 requires OpenGL ES v2 -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<!-- We need to be able to download map tiles and access Google Play Services-->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Allow the application to access Google web-based services. -->
<uses-permission ndroid:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Google Maps for Android v2 will cache map tiles on external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Google Maps for Android v2 needs this permission so that it may check the connection state as it must download data -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- These are optional, but recommended. They will allow Maps to use the My Location provider. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Notice here that we have the package name of our application as a prefix on the permissions. -->
<uses-permission android:name="com.xamarin.docs.android.mapsandlocationdemo2.permission.MAPS_RECEIVE" />
<permission android:name="com.xamarin.docs.android.mapsandlocationdemo2.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<application android:label="@string/app_name">
<!-- Put your Google Maps V2 API Key here. This key will not work for you.-->
<!-- See https://developers.google.com/maps/documentation/android/start#obtaining_an_api_key -->
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="xxxxxxxxxxxxxMY_KEY_HERExxxxxxxxxxxxxxx" />
</application>
</manifest>
我的Android設備正在運行4.0.3。 Google Play服務已安裝並且是我的設備上的最新版本。
任何建議將受到歡迎...
通常這意味着你有錯誤的API密鑰。你使用了哪個密鑰庫?調試一個或一個你自己做的。如果是後者,記得在你的csproj文件中指定它。 – Cheesebaron
謝謝,我正在使用構建期間由IDE創建的調試密鑰庫。我也嘗試刪除這個密鑰庫並重新生成它(通過構建項目),並使用此密鑰庫重新創建我的api密鑰。沒有骰子... –