简体   繁体   English

Android:可以在模拟器上使用Google Maps API吗?

[英]Android: Is it possible to use Google Maps API on emulator?

I'm trying to use Google Maps API on emulator but I'm struggling with it. 我正在尝试在模拟器上使用Google Maps API,但是我为此感到挣扎。 I already set up the API key (I set the package name and SHA-1 on Google console as well) but this error happens. 我已经设置了API密钥(我也在Google控制台上设置了程序包名称和SHA-1),但是会发生此错误。

Here is AndroidManifest.xml : 这是AndroidManifest.xml

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="" />
<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

Google Maps Android API: Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above Google Maps Android API:Google Maps Android API v2仅支持OpenGL ES 2.0及更高版本的设备

Seems like Nexus 5 cannot be used for the Google Maps API on emulator because Emulated Performance is needed to specify to use the Google Maps API. 好像Nexus 5不能用于模拟器上的Google Maps API,因为需要使用“模拟性能”来指定使用Google Maps API。

So I tried to use Nexus 4 instead because I can specify Emulated Performance: Graphics for the device but this error happens on the display. 因此,我尝试使用Nexus 4,因为我可以为设备指定“仿真性能:图形”,但是此错误会在显示屏上发生。

This App won't run until you update Google Play Services. 您必须更新Google Play服务,该应用才能运行。

I looked up this error and all the answers to this error are kind of old so I cannot understand how I can configure it correctly. 我查找了此错误,并且对该错误的所有答案都有些陈旧,所以我无法理解如何正确配置它。

How can I fix these errors? 如何解决这些错误? Has anyone beeen successful in using the API on emulator recently? 最近有没有人成功在模拟器上使用API​​?

You can test the google map api. 您可以测试Google Map API。 Seems like that device is missing google play service and/or might be running at a out of scope api level. 似乎该设备缺少Google Play服务和/或可能在API范围外运行。 The emulator I use without a problem is a Pixel XL. 我没有问题的模拟器是Pixel XL。 Try that emulator or at least make sure the new emulator shows it has google play services 尝试使用该模拟器,或者至少确保新模拟器显示它具有Google Play服务

When creating Virtual device only select device which has play store else play services won't be available . 创建虚拟设备时,仅选择具有播放商店的设备,否则播放服务将不可用。 The latest of all is Pixel 2 so I would suggest using it 最新的是Pixel 2,所以我建议您使用它

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM