gpt4 book ai didi

android - Google Play 服务 - 客户端版本与包版本

转载 作者:行者123 更新时间:2023-11-29 21:03:13 25 4
gpt4 key购买 nike

我已将我现有的 Android 应用程序迁移到 Android Studio/Gradle。我现在的 map 出现了问题,之前它可以正常工作。

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

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

I/Google Maps Android API﹕ Google Play services client version: 5089000

I/Google Maps Android API﹕ Google Play services package version: 5089036

I/Google Maps Android API﹕ Failed to contact Google servers. Another attempt will be made when connectivity is established.

E/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).

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

最佳答案

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

鉴于您已经有一个 API key ,在您的情况下最可能的原因是:

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

  1. 您尚未签署该应用。

  1. list 中缺少权限:
    <uses-permission android:name="android.permission.INTERNET"/>    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>    <!-- The following two permissions are not required to use     Google Maps Android API v2, but are recommended. They are required if you access the user's current location, either programmatically, or by enabling the My Location layer.-->    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

See the app signing / registration description in the getting started section for the Maps API:https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key

Also, you could try adding the following code before loading the map to get more details on the access failure:

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);

关于android - Google Play 服务 - 客户端版本与包版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25365384/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com