【问题标题】:Monodroid Google Maps API v2 - Error contacting Google serversMonodroid Google Maps API v2 - 联系 Google 服务器时出错
【发布时间】:2013-07-24 15:28:42
【问题描述】:

我正在开发一个 MonoDroid 项目,但似乎无法解决这个问题。我正在尝试使用MapsAndLocationDemo_v2 项目,甚至无法将地图加载到 SimpleMapDemo 项目中。我浏览了很多关于这个问题的 SO 帖子。

地图加载但为白色,应用程序输出状态:

[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 中的说明构建了 Google Play 客户端服务库。

我使用位于以下位置的 debug.keystore 生成了一个新的 Android Google Maps 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 文件中指定它。
  • 谢谢,我正在使用 IDE 在构建期间创建的调试密钥库。我还尝试删除此密钥库并重新生成它(通过构建项目)并使用此密钥库重新创建我的 api 密钥。没有骰子...

标签: android xml google-maps xamarin.android


【解决方案1】:

确保您确实使用用于获取 API 密钥的相同密钥签署了您的应用程序。

并且应用程序包与 API 密钥请求中的相同。

我花了几个小时来解决这个问题,才发现应用程序签名有问题。

我已手动签名并显示地图。

【讨论】:

    【解决方案2】:

    查看how to check,如果您的应用使用有效密钥签名 - 否则 Google 地图将无法正常工作,身份验证将被拒绝或其他类似问题。

    还要检查 logcat,它可能会打印出这个问题的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多