【问题标题】:Upgrade Google Play Service on android emulated device [duplicate]在 android 模拟设备上升级 Google Play 服务 [重复]
【发布时间】:2016-07-03 23:44:13
【问题描述】:

我正在使用 android studio 开发应用程序,并使用模拟的 android 设备对其进行测试。模拟设备是带有 Android 4.4 的 Nexus 4(带有 google apis)。

在我的项目中,我使用最新的播放服务客户端版本,9.2.0:

当我在模拟器上启动我的应用程序时,出现以下消息:

问题是:如何升级模拟器上的播放服务?天呐

【问题讨论】:

    标签: android android-emulator google-play-services


    【解决方案1】:

    只需将 Google Play 服务添加到您的项目中即可。要使 Google Play Services API's 可用于您的应用,请在 dependencies 下添加新的构建规则以获取最新版本的 play-services

    打开应用模块目录中的 build.gradle 文件。

    apply plugin: 'com.android.application'
    ...
    
    dependencies {
    compile 'com.google.android.gms:play-services:9.2.0'
    }
    

    确保每次更新 Google Play 服务时更新此版本号。

    Google Play services overview 中所述,Google Play 通过 Google Play Store 应用为 Android 2.3 及更高版本的用户提供服务更新。但是,更新可能不会立即到达所有用户,因此您的应用应在尝试执行 API 事务之前验证可用版本。

    由于每个应用程序使用 Google Play 服务的方式不同,因此由您决定应用程序中的适当位置来验证 Google Play 服务版本。例如,如果您的应用始终需要 Google Play 服务,您可能希望在应用首次启动时执行此操作。另一方面,如果 Google Play 服务是您应用的可选部分,则只有在用户导航到您应用的该部分后,您才能检查版本。

    强烈建议您使用 GoogleApiClient 类来访问 Google Play 服务功能。这种方法允许您将OnConnectionFailedListener 对象附加到您的客户端。要检测设备是否具有适当版本的 Google Play 服务 APK,请实现 onConnectionFailed() 回调方法。如果由于缺少或过期的 Google Play APK 版本导致连接失败,回调会收到错误代码,例如SERVICE_MISSING

    【讨论】:

    • 我已经在使用最新的播放服务了。这不是项目设置或依赖关系问题。问题是我无法在模拟器上升级 google play 服务。
    猜你喜欢
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 2015-08-02
    • 2015-12-25
    • 1970-01-01
    • 2015-08-26
    • 2015-08-14
    • 1970-01-01
    相关资源
    最近更新 更多