【问题标题】:Google Play Services - Client Version vs Package VersionGoogle Play 服务 - 客户端版本与软件包版本
【发布时间】:2014-10-11 11:44:26
【问题描述】:

我已将现有的 Android 应用迁移到 Android Studio / Gradle。我的地图现在有问题,以前可以使用。

我从 Google 克隆了 android-maps-utils 库并将其添加到我的项目中。我已将 android-map-utils 的依赖项添加到我的 gradle.build 文件中。

当我加载包含地图的屏幕时,我从 LogCat 获得以下序列:

I/Google Maps Android API:Google Play 服务客户端版本: 5089000

I/Google Maps Android API:Google Play 服务包版本:5089036

我/Google Maps Android API:未能联系 Google 服务器。连接成功时将进行另一次尝试 已确立的。

E/Google Maps Android API:加载地图失败。错误 联系 Google 服务器。这可能是身份验证问题 (但可能是由于网络错误)。

我要去获取一个新的 Maps API 密钥,但我很好奇是否有人认为 Google Play 服务客户端版本/包版本的差异可能会导致问题,然后我该如何解决?

【问题讨论】:

  • 您是否在启动应用时检查 google play 服务是否更新?
  • 它正在检查 Google Play 服务是否可用(它返回 TRUE / Available),但如果版本旧,我认为它不会进行任何类型的自动更新。

标签: android google-maps gradle android-studio google-play-services


【解决方案1】:

显示的软件包版本比客户端版本新,因此在您的情况下,这不是版本兼容性问题。

鉴于您已经拥有 API 密钥,您的情况最可能的原因是:

  1. 您尚未在授权应用列表中注册已签名应用的 SHA-1 指纹,以便在 Google API 控制台中访问您的 API 密钥(即使是经过调试签名的应用,您也需要这样做)

  1. 您尚未签署应用程序。

  1. 清单中缺少权限:

请参阅 Maps API 入门部分中的应用签名/注册说明: https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key

另外,您可以尝试在加载地图之前添加以下代码以获取有关访问失败的更多详细信息:

String googleError = null;
switch (MapsInitializer.initialize(ctx)) { // or GooglePlayServicesUtil.isGooglePlayServicesAvailable(ctx)
    case ConnectionResult.SERVICE_MISSING: googleError = "Failed to connect to google mapping service: Service Missing"; break;
    case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED: googleError = "Failed to connect to google mapping service: Google Play services out of date. Service Version Update Required"; break;
    case ConnectionResult.SERVICE_DISABLED: googleError = "Failed to connect to google mapping service: Service Disabled. Possibly app is missing API key or is not a signed app permitted to use API key."; break;
    case ConnectionResult.SERVICE_INVALID: googleError = "Failed to connect to google mapping service: Service Invalid. Possibly app is missing API key or is not a signed app permitted to use API key."; break;
    case ConnectionResult.DATE_INVALID: googleError = "Failed to connect to google mapping service: Date Invalid"; break;
}
if (googleError != null)
    Log.d("MyApp", googleError);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 2018-12-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多