Android Studio 模拟器 Google Play 服务

标签 android android-emulator google-play-services

我正在按照本教程 https://developer.android.com/training/location/retrieve-current.html 尝试从 Android Studio 获取我的 Android 模拟器中的最后一个已知位置

然而,回调方法onConnectionFailederror code: 2 调用.当我在模拟器中显示错误对话框时,它显示:

Update Google Play Services

{app_name} won't run unless you update Google Play services.

UPDATE

当我点击 UPDATE按钮,我收到一条错误消息:

E/SettingsRedirect﹕ Can't redirect to app settings for Google Play services

我认为问题是因为 Google Play 服务未包含在模拟器中。我也尝试按照这里的答案Android Studio with Google Play Services , 但它没有用。

Google 文档上说:

To test your app when using the Google Play services SDK, you must use either:

1.) A compatible Android device that runs Android 2.3 or higher and includes Google Play Store.

2.) The Android emulator with an AVD that runs the Google APIs platform based on >Android 4.2.2 or higher.

有人能告诉我第 2 点怎么做吗? 我的 AVD 是 Nexus 5 API 22 x86

最佳答案

Here版本图表 4.2.2 意味着它应该是 API 级别 17 及更高级别。所以你的 AVD 应该没问题。或者,您可以下载 Google Play Services APK 并通过 ADB shell 安装。参见 this回答更多信息。

但是,即使 Play 服务问题得到解决,您也无法在模拟器中获取位置更新,因为它没有 GPS 硬件。您可以通过 geo 命令模拟位置行为,如所述 here .

关于Android Studio 模拟器 Google Play 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31794898/

相关文章:

android - 如何模仿 Lollipop 的手机应用程序,在可滚动内容之前调整上部项目的大小?

内部存储器上的Android公共(public)文件

android - 从 Android 联系人数据库获取联系人 ID 未按预期工作

android - 为什么安卓平板模拟器这么慢?有没有办法加快速度?

android - 在我的实时设备上运行代码时,Firebase 作业调度程序不会触发我的 JobService 类,为什么?

android - 华为设备: The meta-data tag in your app's AndroidManifest. xml没有正确的值

java - Android:Twitter4J 异常(接收到的身份验证质询为空)

java - 调用notifyItemChanged后,适配器不会收到通知,并且onBindViewHolder不会被调用

java - 从 Android 中的 apk 文件中读取 Activity 名称

Android:如何从服务调用 startResolutionForResult?