Android MapActivity:无法获得连接工厂客户端 [英] Android MapActivity : Couldn't get connection factory client

查看:32
本文介绍了Android MapActivity:无法获得连接工厂客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照 Google API 中提供的方式运行地图演示示例项目.我正在使用 AVD 并尝试过版本 8、10和 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).

但是,我无法通过 DDMS 或 Telnet 在地图上设置位置.一世在 LogCat 中看到以下错误:MapActivity:无法获得连接工厂客户端

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

我已经阅读了许多关于这个问题的主题,但它们似乎总是由于 API 密钥错误;我没有,因为我检索地图图块.

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());
           }
       });

我看到了我的第一个日志语句,但从来没有看到第二个,以及MapActivity:无法获得连接工厂客户端"被写入 LogCat点.

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.

我已经读到 SDK v8 模拟器存在问题,所以我有尝试使用 v10 和 11 - 但仍然没有快乐.我还没有在实际设备上尝试过 - 很快就会完成.

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  ;)

干杯

推荐答案

我的初始情况与您描述的完全相同.

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.你需要一个位置.我认识到仅通过 DDMS 视图为模拟器设置地理位置是不够的.您必须在每次 DDMS 中的发送"按钮时明确按下以触发模拟器上的位置更新.(只是提一下:在真实的设备上,您有时需要走一点路才能让您的设备获得位置更新;),我很生气,直到我四处走动思考现在该做什么^^)

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.您需要使用正确的 OverlayItem 正确实现 ItemizedOverlay.我写了自己的叠加层,这有点复杂".如果您不确定您的实现是否正确,请使用本指南创建一个更改最少的实现 Android 开发者地图视图教程

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

或者使用这个:

private class MyItemizedOverlay extends ItemizedOverlay {
    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();

    public MyItemizedOverlay(Drawable defaultMarker) {
          super(boundCenterBottom(defaultMarker));
    }

    public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
    }

    @Override
    protected OverlayItem createItem(int i) {
      return mOverlays.get(i);
    }

    @Override
    public int size() {
      return mOverlays.size();
    }
}

private void updateLocationOverlay() {
    if (location == null) { return };
    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.XXXX);
    MyItemizedOverlay myItemizedOverlay = new MyItemizedOverlay(drawable);
    GeoPoint point = new GeoPoint((int)(location.getLatitude() * 1E6), (int)(location.getLongitude() * 1E6));

    OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
    myItemizedOverlay.addOverlay(overlayitem);
    mapOverlays.add(myItemizedOverlay);
}

我想特别指出,你必须在可绘制对象上调用 boundCenter 或 boundCenterBottom.否则它不会被绘制.如果您在与overlayItem.setMarker 相同的叠加层中使用不同的标记,也要小心,您也在那里称它为.

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.您必须将地图上的视图移动到您的位置.你可以这样实现:

MapController mapController = mapView.getController();
mapController.setCenter(point)

我认识到函数 mapController.zoomToSpan 不起作用.(至少对我来说,我仍在开发这个应用程序).也许它与 animateTo 相同.我没有尝试.设置中心工程.(也设置缩放级别).

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.

祝你好运!

我忘了提到我仍然收到工厂客户端错误,即使它可以通过ddms发送获得有效的位置,在设备上是真实的,在模拟器上是假的).我暂时忽略.

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.

这篇关于Android MapActivity:无法获得连接工厂客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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