gpt4 book ai didi

Android Studio 模拟器 Google Play 服务

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:13:15 24 4
gpt4 key购买 nike

我正在按照本教程 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/

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