android - 如何为我的 Google map 应用程序使用具有 Google Play 服务依赖性的非 Nexus 5 模拟器

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

我的测试方法涉及使用许多不同配置的模拟器(品牌/型号/尺寸/API/目标)。

我最近升级到 Android Studio 3.1。

我的应用程序已经运行了 3 年并使用了 Google Maps v2,我想继续维护它(Google 笑)。

我现在拥有的所有模拟器(Nexus 5 除外)都无法正常工作,因为它表示需要更新 Google Play 服务,而且似乎没有解决该问题的途径。 Nexus 5 模拟器没有错误,但显示空白 map 背景。

当我尝试删除对 Google Play 服务的任何依赖时,它最终会变得很滑(主要是替换融合位置服务)。

问题:如果我的 Google map v2 应用依赖于 Google Play 服务(也许是我的第一个错误?),我是否只能使用 Nexus 5 模拟器(这似乎有其自身的问题) ?如果没有,那么如何升级其他优秀的模拟器(Pixel、其他 Nexus、Galaxy...)?

我看到其他问题,我会继续关注它们,但我想了解什么是 future 维护的可行途径 - 删除依赖项,升级某些东西......

供引用:

非 Nexus 5 相关错误是:

(app) won't run unless you update Google Play services

(A big fat 'Update' button is also displayed which throws an exception - presumably because it is not installed on the emulator.)

与 Nexus 5 相关的错误是:

E/Google Maps Android API: Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above

(Which I can't enable in the AVD manager for Nexus 5 emulators.)

这是一些典型的 gradle 疯狂 - 我试图将播放服务降低到 11.8.0 并且这个不幸的魔法发生了(来自 gradlew app:depencencies):

+--- com.google.android.gms:play-services-maps:11.8.0 -> 12.0.1 | +--- com.google.android.gms:play-services-base:12.0.1 | | +--- com.google.android.gms:play-services-basement:12.0.1 | | |
+--- com.android.support:support-v4:26.1.0 () | | | --- com.google.android.gms:play-services-basement-license:12.0.1 | |
+--- com.google.android.gms:play-services-tasks:12.0.1 | | | +--- com.google.android.gms:play-services-basement:12.0.1 (
) | | | --- com.google.android.gms:play-services-tasks-license:12.0.1 | | --- com.google.android.gms:play-services-base-license:12.0.1 |
+--- com.google.android.gms:play-services-basement:12.0.1 (*) | --- com.google.android.gms:play-services-maps-license:12.0.1

庆典

@xiaomi 正确地将问题归因于 play-services(或特别是 play-services-maps)12.0.1,所以在一些 gradle 战斗之后我将所有 play-* 降低到 11.8.0 并且非 Nexus 模拟器工作。

经验教训:

  • 切勿盲目按照 gradle warning-advice 升级版本!
  • “gradlew app:dependencies”是你的 friend 。

结语

在执行此操作之前请三思:

enter image description here

最佳答案

我们可以使用的最新 Google Play 服务与最新模拟器可以处理的服务之间通常存在延迟。

当模拟器上的应用要求更新时,一种解决方案是使用较低版本的 Google Play 服务。

如果 map 显示为空白,通常是 key registration 有问题

关于android - 如何为我的 Google map 应用程序使用具有 Google Play 服务依赖性的非 Nexus 5 模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49708168/

相关文章:

java - 使用 Robolectric + Roboguice 时将日志输出写入哪里?

java - Android Studio 应用程序可在模拟器中运行,但不能在真实设备上运行

android - 即使安装了 google play,facebook 应用程序也无法在 genymotion 模拟器 2.0.1 上运行

Android:Emulator -ramdisk 命令行选项损坏

android - 在 recyclerView 中禁用点击动画

android - 如何获得可用的网络运营商? (使用 RIL 和非 API 方法)

php - 使用 json rereiver php mysql 填充 fragment 中的 ListView

javascript - 使用 Google Maps API v3 中的 Sprite 标记图标缩放标记大小

javascript - 出现非常奇怪的 javascript 错误,并且此页面也拒绝在 Internet Explorer 7 或 8 中工作

java - 更新后如何获取位置?