Android MapActivity:无法获取连接工厂客户端
我正在尝试让地图演示正常工作,如 Google API 中提供的那样 示例项目。我正在使用 AVD,并尝试过版本 8、10 和 11 并得到同样的问题。
我已经生成了自己的调试密钥并添加到项目中。 我可以看到 应用程序上的地图启动,并且可以放大等 - 所以我得到了地图 瓷砖,不错。 是 - 我在清单中设置了正确的权限和库 文件(根据样本)。
但是,我无法通过 DDMS 或 Telnet 在地图上设置位置。我 在LogCat中看到以下错误: MapActivity:无法获取连接工厂客户端
我已经阅读了大量有关此问题的线程,但它们似乎总是 由于 API 密钥错误而导致;我没有,因为我就是这样 检索地图图块。
所以我创建了自己的项目来进一步测试这一点,并正在执行 以下是关于地图初始化的代码:
myLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
myLocationOverlay.enableMyLocation();
Log.i("funkatron: ", "ABOUT TO CALL RUN ON FIRST FIX");
myLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
String loc = "we have a location, executing AnimateTo().
"+myLocationOverlay.getMyLocation().toString();
Log.i("funkatron:",loc);
mapController.animateTo(myLocationOverlay.getMyLocation());
}
});
我看到了第一个日志语句,但从未看到第二个日志语句,并且“MapActivity: 无法获取连接工厂客户端”被写入 LogCat 观点。
我读到 SDK v8 模拟器存在问题,所以我有 尝试过 v10 和 11 - 但仍然没有乐趣。 我还没有在实际设备上尝试过这个 - 很快就会尝试。
对于这个问题的任何帮助将不胜感激 - 这真的是 让我困惑 )
欢呼
I'm trying to get the Map demos working, as provided in the Google API
sample projects. I am using AVDs and have tried with versions 8, 10
and 11 and get the same issue.
I've generated my own debug key and added to the project. I can see
the map on app start up, and can zoom in etc - so I am getting the map
tiles, fine.
Yes - I have the correct permissions and library set in the Manifest
file (as per samples).
But, I cannot set a location on the map, either via DDMS or Telnet. I
see the following error in LogCat:
MapActivity : Couldn't get connection factory client
I've read numerous threads regarding this issue, but they always seem
to be as a result of a bad API key; which I do not have, as I am
retrieving map tiles.
So I created my own project to test this further, and am executing the
following code on initialisation of my map:
myLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
myLocationOverlay.enableMyLocation();
Log.i("funkatron: ", "ABOUT TO CALL RUN ON FIRST FIX");
myLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
String loc = "we have a location, executing AnimateTo().
"+myLocationOverlay.getMyLocation().toString();
Log.i("funkatron:",loc);
mapController.animateTo(myLocationOverlay.getMyLocation());
}
});
I see my first log statement, but never the second, and "MapActivity :
Couldn't get connection factory client" is written to LogCat at that
point.
I have read that there were issues with SDK v8 emulators, so I have
tried with v10 and 11 - but still no joy.
I have NOT yet tried this on an actual device - will do soon.
Any help on this issue would be greatly appreciated - it's really
baffling me ;)
cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我的初始情况与你所描述的完全相同。
当您看到地图图块时,显然缺少一些在地图上看到的位置:
1。您需要一个位置。
我认识到仅通过 DDMS 视图向模拟器设置地理位置是不够的。您必须在每次 DDMS 中明确按下“发送”按钮才能触发模拟器上的位置更新。
(只是提一下:在真实的设备上,有时您需要走一段路才能使设备获得位置更新;),我很生气,直到我四处走动思考现在该做什么^^)
2 。您需要使用正确的 OverlayItem 正确实现 ItemizedOverlay。
我写了自己的覆盖,有点“复杂”。如果您不确定您的实现是否正确,请使用本指南以最小的更改创建一个实现 地图视图教程 android 开发人员
或使用这个:
我想特别指出,您必须在可绘制对象上调用boundCenter或boundCenterBottom。否则不会被绘制。如果您在同一个覆盖层中使用overlayItem.setMarker 的不同标记,也要小心,您也在那里调用它。
3.您必须将地图上的视图移动到您的点。你可以这样实现:
我认识到函数 mapController.zoomToSpan 不起作用。 (至少对我来说,我仍在开发这个应用程序)。也许它与 animateTo 相同。我没有尝试。设置中心工作。 (还有设置缩放级别)。
也许我提到的几点可能会导致您的地图无法按您想要的方式工作。
祝你好运!
编辑:我忘了提及,即使它可以通过 ddms 发送获取有效位置(在设备上是真实的,在模拟器上是假的),我仍然收到工厂客户端错误。我暂时忽略。
i had exactly the same initial situation as you described.
when you see the map tiles there are obviously some missing to see a position on the map:
1. you need a location.
i recognized that setting only a geo position via DDMS view to the emulator is not enough. you have to explicitly press every time the "Send" button in DDMS to trigger a location update on your emulator.
(just to mention: on a real the device you have sometimes to walk a bit to make your device get a location update ;), i was so pissed off until i walked around thinking of what to do now ^^)
2. you need a correct implementation of ItemizedOverlay with an correct OverlayItem.
i wrote my own overlay which got bit "complicated". if you're not sure if your implementation is correct, use this guide to create an implementation with minimal changes Map view tutorial android developers
or use this:
i want specially point out that you must call boundCenter or boundCenterBottom on the drawable. else it will not be drawn. be also careful if you use different markers in the same overlay with overlayItem.setMarker, that u call it there too.
3. you have to move the view on the map to your point. you can achieve this like this:
i recognized that the function mapController.zoomToSpan does not work. (at least for me, i am still developing on this app). maybe its the same with animateTo. i did not try. set center works. (and setZoom level also).
Maybe there is something in the points i mentioned which could lead to, that your map does not work like you want.
Good luck!
edit: i forgot to mention that i am still getting that factory client error even it works to get a valid location, real on device and fake on emulator via ddms send). i just ignore for now.
请确保您在应用程序 AndroidManifest.xml 中使用权限。
在 AndroidManifest.xml 中添加这 3 行
,并确保密钥库指向您创建的密钥库。
在 Eclipse 中检查窗口 ->首选项 ->Android ->Build :默认调试密钥库,指向您使用 keytool 创建的密钥,否则使用浏览按钮并指向实际密钥。
Please make sure that you use permissions in your application AndroidManifest.xml.
add these 3 lines in AndroidManifest.xml
And also make sure keystore is pointing to the keystore you created.
In eclipse Check Window -> Preferences ->Android ->Build : Default Debug keystore, is pointing to the key you created using keytool, else use Browse button and point to the actual key.
各位开发人员大家好,
我也遇到过这个问题,花了近半天的时间试图弄清楚到底发生了什么。最初,地图活动根本不会显示,并且我收到一条错误,指出“无法获取连接工厂客户端”,这又创建了另一个错误“java.io.IOException:服务器返回 3”。
其原因是 Google 未能与他们的开发基地进行有效沟通,即在开发过程中,即在签署和发布您的应用程序之前,您必须使用测试时使用的调试密钥对您的应用程序进行签名。为此,请按照以下方法将[密码]和[密钥密码]替换为您自己的密码。
从您的 .android 目录中,发出以下命令:
执行上述操作后,您将很高兴收到 MD5 证书指纹,您可以使用它来注册 Google 地图 API 密钥。替换项目中的 Google 地图 API 密钥,执行项目清理并重新运行您的应用程序。您现在应该能够查看您的 Google 地图并消除恼人的错误。
如何获取 Google 地图 Android API 密钥
Hello fellow developers,
I too experienced this issue and spent nearly half a day trying to figure out what was going on. Initially the map activity would not display at all and I was receiving an error stating, "Couldn't get connection factory client" which in turn created another error, "java.io.IOException: Server returned 3".
The cause of this is that Google have failed to communicate effectively to their development base that whilst in development, i.e. prior to signing and releasing your application, you must sign your application with a debug key which is used whilst testing. To do so, follow the method below replacing the [password] and [key password] with your own passwords.
From your .android directory, issue the following command:
Upon doing the above you will be pleased to receive your MD5 Certificate fingerprint which you can use to sign up for your Google maps API key. Replace your Google Maps API key in your project, do a Project Clean and re-run your applicat6ion. You should now be able to view your Google Map and be rid of your annoying errors.
How to obtain a Google Maps Android API Key
我遇到了同样的问题“MapActivity 无法获取连接工厂客户端”
我解决问题的方法非常简单!我刚刚卸载了整个应用程序并重新安装了它。成功了!!!
I had the same problem with "MapActivity Couldn't get connection factory client"
The way I fixed the problem was very simple! I just uninstalled entire application and reinstalled it. It worked!!!
我遇到了同样的问题,问题是当我为 MapActivity 设置适当的布局时我错过了
代码是
main.xml 布局文件不包含任何地图视图,
它
具有以下 XML 代码
地图现在正在工作,希望这会有所帮助
另外您还可以检查是否已在地图视图布局中添加了任何内容因为添加此类视图会导致此错误
I faced the same problem and the problem was that I missed when I set the appropriate layout to the MapActivity
the code was
the main.xml layout file doesn't contain any mapview
it became
which have the following XML code
The map is working fid right now , hope this would help
Also you can check if you 've added any thing to your mapview layout because adding such views would result in this error
发生这种情况似乎有多种原因。我已经修复了这个问题,将我的项目构建目标更改为 api 10(rclick 项目 /Properties/Android),然后在 api 级别 15 的模拟器上运行(尽管非常非常慢!)。
There seem to be mulitple reasons for this happening. I've fixed it altering my project build target to api 10 (rclick on the project /Properties/Android) and then running on an emulator at api level 15 (albeit very, very slowly!).
我对下面的 main.xml 遇到了同样的问题
然后我将 main.xml 更改为如下,问题解决了
I had the same problem with below main.xml
Then i changed the main.xml to as below, the problem was solved
楼上已经有人评论了:重启手机。
或者,如果您在模拟器中运行:重新启动模拟器。
Somebody up there already said it in a comment: Restart the phone.
Or if you're running in emulator: Restart the emulator.