无法模拟Android模拟器位置数据 [英] Unable to simulate location data in Android emulator

查看:5876
本文介绍了无法模拟Android模拟器位置数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试我的应用程序,它使用地理位置使用模拟器。几种方法被描述<一href=\"http://stackoverflow.com/questions/2279647/how-to-emulate-gps-location-in-the-android-emulator\">here.我要去窗口 - &GT;开放Perspective-&GT; DDMS ,然后输入经纬度。而长。之一位置控制然后我点击发送

I'm trying to test my app, which uses geolocation using the emulator. Several methods are described here. I'm going to Window->Open Perspective->DDMS, then entering lat. and long. one in Location Controls and then I hit "Send".

但它不工作。相反,我看到以下错误:无法发送命令到模拟器

But it doesn't work. Instead I see the following error: Unable to send command to the emulator.

这是怎么回事!?

我不认为我的应用程序是问题,因为我用模拟器的默认浏览器测试,它也不能访问的位置信息。

I don't think my app is the problem because I tested with the emulator's default browser and it also cannot access location info.

详细内容:


  • OSX 10.9.4

  • AVD_for_Nexus_4_by_Google瞄准v4.4.2

  • 的Eclipse IDE Android开发23.0.2.1259578

更新:
我改成 AVD_for_Galaxy_Nexus_by_Google ,它仍然无法正常工作,但我再也看不到这个错误。我点击发送,并没有任何反应。

Update: I changed to AVD_for_Galaxy_Nexus_by_Google and it still doesn't work, but I no longer see that error. I click send and nothing happens.

UPDATE2:
我已经使用Telnet位置数据传递给模拟器测试,再没有任何反应。没有错误。根本不值一提。 Urgh!

Update2: I've tested using Telnet to pass location data to the emulator, and again nothing happens. No errors. Just nothing. Urgh!

telnet localhost 5554
geo fix 50 50

这与确定但没有任何反应响应。仍然没有位置数据可用。

It responds with OK but nothing happens. Still no location data available.

UPDATE3:
我注意到下面的错误在LogCat中流

Update3: I notice a stream of the following errors in LogCat

09-20 17:58:59.910: E/eglCodecCommon(1777): glUtilsParamSize: unknow param 0x00000b44
09-20 17:58:59.910: E/eglCodecCommon(1777): glUtilsParamSize: unknow param 0x00000bd0
09-20 17:58:59.930: E/eglCodecCommon(1777): **** ERROR unknown type 0x0 (glSizeof,72)

该应用程序似乎要被罚款运行,并且这些错误理应解释<一个href=\"http://stackoverflow.com/questions/22348801/phonegap-eclipse-issue-egl$c$cccommon-glutilsparamsize-unknow-param-errors\">here.

更新4:
我已经看到了多个建议,以确认我的AVD启用了GPS的支持,但该选项/设置不会出现在任何地方。当我打开Android虚拟设备管理器,然后点击我的设备之一的编辑,这是我所看到的:

Update 4: I've seen multiple suggestions to confirm that my AVD has GPS Support enabled, but this option/setting does not appear anywhere. When I open the "Android Virtual Device Manager" and then click "Edit" on one of my devices, this is what I see:

的GPS支持没有提及。

No mention of "GPS Support".

更新5:
我检查了我所有的自动真空淀积系统config.ini文件,他们都正确设置为 hw.gps = YES 。我还创建了使用谷歌API的目标AVD,但是我仍然有同样的问题。该应用程序加载,但没有位置数据是可用的,用位置控制,以及远程登录。

Update 5: I checked the config.ini file for all my AVDs and they are all correctly set to hw.gps=yes. I also created an AVD using a Google API target, however I'm still having the same problem. The app loads but no location data is available, with "Location Controls" as well as telnet.

更新6:
按照下面Gyebro的建议...尝试加载自己的LocationDemo应用...

Update 6: Following Gyebro's suggestions below... trying to load his LocationDemo app...

这就是我看到在LogCat中:

Here's what I see in the LogCat:

推荐答案

要检查您的仿真器是否支持GPS,转到〜/ .android / AVD /&LT; emulatorname&GT; .avd / 和检查的config.ini 硬件qemu.ini (如果存在的话),他们应该包含以下内容:

To check whether your emulator supports GPS, go to ~/.android/avd/<emulatorname>.avd/ and check config.ini and hardware-qemu.ini (if exists) they should contain:

hw.gps = YES

hw.gps = yes

修改结果
您必须使用谷歌API的系统映像。你应该设置谷歌的API - API等级1#作为目标


编辑的结束

假如是这样的话,而且位置是在模拟器启用,在模拟器中运行这个测试应用程序:的 LocationTest演示,详情请参见开发文档上检索当前位置

Assuming this is so, and Location is enabled in your emulator, run this test application in your emulator: LocationTest demo, for details see the Dev docs on Retrieving the Current Location

本示例实现 GooglePlayServicesClient.ConnectionCallbacks GooglePlayServicesClient.OnConnectionFailedListener LocationListener的。而且还检查谷歌与LocationClient连接之前播放服务(这就是为什么我们需要一个谷歌模拟器图像。)(参见<一个href=\"https://github.com/Gyebro/android-demos/blob/master/LocationTest/app/src/main/java/com/gyebro/locationtest/MainActivity.java\"相对=nofollow> MainActivity.java )

This sample implements GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener and LocationListener. And also checks for Google Play Services before connecting with the LocationClient (that's why we needed a Google Emulator image.) (See MainActivity.java)

在你启动应用程序,你应该看到在状态栏中的图标位置。也可以验证,即GP服务是present和LocationClient连接在日志中。

After you start the app, you should see the Location icon in the status bar. Also verify, that the GP Services are present and the LocationClient is connected in the Log.

 D/LocationTest﹕ Google Play services is available.
 D/LocationTest﹕ LocationClient: Connected

在发送了地理修复66 80 使用telnet或其他的有效的(应确定回应)的使用DDMS坐标,你应该看到:

After sending geo fix 66 80 using telnet (should respond with OK) or other valid coordinates using DDMS, you should see:

 D/LocationTest﹕ Location changed!

如果你还在使用这种方法丢失,另一种方式来模拟地点是创建一个模拟位置提供应用

If you are still lost with this approach, another way to simulate locations is to create a Mock Location Provider app.

这篇关于无法模拟Android模拟器位置数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆