【问题标题】:How to update Google Play Services to 9.8.7 for running on Google Pixel如何将 Google Play 服务更新到 9.8.7 以在 Google Pixel 上运行
【发布时间】:2016-10-26 13:34:08
【问题描述】:

我正在尝试实现我的应用程序,按照https://developers.google.com/android/guides/setup 的说明,在我的 build.gradle 文件中将 Google Play 服务设置为 9.8.0。如How to update Google Play Services to 9.8.7 中所述,为了在模拟器上进行测试,我应该降级服务。但是,它也表明它应该在物理设备上工作。

  • 我正在使用安装了 Google Play 服务 9.3.84 的新 Google Pixel 手机,Android 7.1。
  • build.gradle 文件包括:compile 'com.google.android.gms:play-services:9.8.0'
  • 运行 adb 调试器后显示

I/FirebaseInitProvider:FirebaseApp 初始化不成功

W/GooglePlayServicesUtil:Google Play 服务已过期。需要 9877000 但找到 9384448

E/MainActivity:与 Google API 客户端的连接失败

我已经在 SDK 管理器/工具(版本 37)中更新了 Google Play 服务,但我的想法已经不多了。我不确定如何降级 Pixel 上的 Google Play 服务。我是否遗漏了什么(可能很明显?)

EDTI:查看答案,我错过了手机上正确版本的 Google Play 服务。该解决方案实施检查以防止将来出现错误。

【问题讨论】:

    标签: android android-gradle-plugin google-play-services android-7.1-nougat


    【解决方案1】:

    您应该添加一些代码来检查是否需要更新。像下面这样。

    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
        googlePlayServicesAvailable = googleApiAvailability.isGooglePlayServicesAvailable((Variables.context));
            if ((googlePlayServicesAvailable == ConnectionResult.SERVICE_MISSING) || (googlePlayServicesAvailable == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED) || (googlePlayServicesAvailable == ConnectionResult.SERVICE_DISABLED)) {
                                activity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
                                googleApiAvailability.getErrorDialog(((Activity) Variables.context), googlePlayServicesAvailable, 0);
            }
    

    您应该将我的代码修改为:

    1. 询问用户是否要升级
    2. 如果 Play 商店未安装,请使用 ActivityNotFoundException 捕获

    【讨论】:

    • 你是完全正确的。事实证明,正如我的问题所述,我安装了旧版本的 Google Play 服务(9.3.84,而不是 9.8.77)。快速解决方法是在 chrome 上(在手机上)搜索应用程序并请求更新。我目前正在实施您的解决方案,因为无论 Android 手机/Google Play 服务版本如何,这都能解决问题。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2017-03-11
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 2016-02-27
    • 2015-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多