简体   繁体   English

GPS在模拟器中不起作用

[英]GPS not working in emulator

I'm developing an app that uses LocationManager.GPS_PROVIDER to request location updates. 我正在开发一个使用LocationManager.GPS_PROVIDER来请求位置更新的应用。 Everything is working on my Samsung Galaxy S5, but in the emulator I get the exception "java.lang.IllegalArgumentException: provider doesn't exist: gps" when calling requestLocationUpdates(). 一切都在我的Samsung Galaxy S5上运行,但是在模拟器中,当调用requestLocationUpdates()时,出现异常“ java.lang.IllegalArgumentException:提供者不存在:gps”。

GPS is enabled in the emulator (both in "Settings" and "Google Settings") and it is set to "High Accuracy". 在模拟器中启用了GPS(在“设置”和“ Google设置”中均已启用),并且将其设置为“高精度”。

I've tried setting the location via Android Studio's Extended emulator controls, and using the command line (telnet, geo fix lat lon alt). 我尝试通过Android Studio的扩展仿真器控件并使用命令行(telnet,地理修复纬度alt)来设置位置。

The latest SDK tools are installed (25.2.2 rc1), and the emulator is using these ("About" displays Emulator version 25.2.2-3098464). 安装了最新的SDK工具(25.2.2 rc1),并且仿真器正在使用这些工具(“关于”显示仿真器版本25.2.2-3098464)。

Thanks for your help 谢谢你的帮助

I'd advise that you simply use GenyMotion - It's a nice emulator and would easily do what you're trying to do. 我建议您只使用GenyMotion-这是一个不错的模拟器,可以轻松完成您要尝试执行的操作。 You would need to specify the coordinates in the free version. 您需要在免费版本中指定坐标。 I'm not sure of the paid version. 我不确定付费版本。 The link is here . 链接在这里 Cheers 干杯

My emulator was using API 19 (the same as my real device). 我的模拟器使用的是API 19(与我的真实设备相同)。 I just tried creating a new one using API 22, and in this emulator it does work. 我只是尝试使用API​​ 22创建一个新的,并且在此模拟器中可以正常工作。 Still no clue as to why it doesn't work on the other emulator, all system images/SDK tools are installed and everything seems properly configured. 仍然不知道为什么它不能在其他仿真器上运行,所有系统映像/ SDK工具都已安装,并且所有配置似乎都正确配置。

If you list the providers available in the API19 emulator (getAllProviders) you will notice that gps is not available. 如果列出了API19仿真器中可用的提供程序(getAllProviders),您会注意到gps不可用。 API22 Emulator has not this mistake. API22 Emulator没有这个错误。

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

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