无法获得连接工厂客户端

时间:2011-05-01 13:08:44

标签: java android

一切正常,但问题是当我映射一个位置时没有任何事情发生 我注册了我的谷歌地图,我在这里做了每一个指令

http://code.google.com/intl/pl/android/add-ons/google-apis/mapkey.html

我可以看到我可以放大的地图& out,但当我在寻找一个位置时,我会在logcat中找到它

05-01 12:59:35.512: ERROR/MapActivity(488): Couldn't get connection factory client
05-01 12:59:36.012: INFO/ActivityManager(70): Displayed TaskManager.com/.AddLocationMapActivity: +4s562ms
05-01 12:59:36.692: WARN/KeyCharacterMap(488): No keyboard for id 0
05-01 12:59:36.692: WARN/KeyCharacterMap(488): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
05-01 12:59:41.192: DEBUG/dalvikvm(238): GC_EXPLICIT freed 6K, 54% free 2543K/5511K, external 410K/517K, paused 77ms
05-01 12:59:46.352: DEBUG/dalvikvm(318): GC_EXPLICIT freed 6K, 54% free 2597K/5639K, external 410K/517K, paused 158ms
05-01 12:59:51.362: DEBUG/dalvikvm(352): GC_EXPLICIT freed <1K, 54% free 2539K/5511K, external 410K/517K, paused 144ms
05-01 12:59:54.262: WARN/System.err(488): java.io.IOException: Service not Available
05-01 12:59:54.272: WARN/System.err(488):     at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
05-01 12:59:54.282: WARN/System.err(488):     at TaskManager.com.AddLocationMapActivity.mapCurrentLocation(AddLocationMapActivity.java:59)
05-01 12:59:54.282: WARN/System.err(488):     at TaskManager.com.AddLocationMapActivity$1.onClick(AddLocationMapActivity.java:49)
05-01 12:59:54.292: WARN/System.err(488):     at android.view.View.performClick(View.java:2485)
05-01 12:59:54.302: WARN/System.err(488):     at android.view.View$PerformClick.run(View.java:9080)
05-01 12:59:54.302: WARN/System.err(488):     at android.os.Handler.handleCallback(Handler.java:587)
05-01 12:59:54.332: WARN/System.err(488):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-01 12:59:54.332: WARN/System.err(488):     at android.os.Looper.loop(Looper.java:123)
05-01 12:59:54.342: WARN/System.err(488):     at android.app.ActivityThread.main(ActivityThread.java:3683)
05-01 12:59:54.342: WARN/System.err(488):     at java.lang.reflect.Method.invokeNative(Native Method)
05-01 12:59:54.352: WARN/System.err(488):     at java.lang.reflect.Method.invoke(Method.java:507)
05-01 12:59:54.362: WARN/System.err(488):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-01 12:59:54.362: WARN/System.err(488):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-01 12:59:54.372: WARN/System.err(488):     at dalvik.system.NativeStart.main(Native Method)

这是我的java代码

 protected void mapCurrentLocation() {
            String addressString = addressText.getText().toString();
            Geocoder g = new Geocoder(this,Locale.getDefault());
            List<Address> addresses;
            try
            {
//when i use the debugger i get exception at next line 
                addresses = g.getFromLocationName(addressString, 1);
                if(null != addresses && addresses.size()>0)
                {
                    address=addresses.get(0);
                    List<Overlay> mapOverlay=mapView.getOverlays();
                    AdreesOverlay addressoverlay = new AdreesOverlay(address);
                    mapOverlay.add(addressoverlay);
                    mapView.invalidate();
                    final MapController mapController=mapView.getController();
                    mapController.animateTo(addressoverlay.getGeopoint(),new Runnable(){
                        public void run() { 
                            mapController.setZoom(12);
                        }});
                }
                else
                {

                }
            }
            catch(IOException exception)
            {
                exception.printStackTrace();
            }
        }

任何帮助?提前谢谢

2 个答案:

答案 0 :(得分:2)

如果您在模拟器中运行此版本API 8或API 9,这是模拟器的已知错误,请参阅此错误报告service not available

我发现了同样的行为。我可以让它在API级别7模拟器(2.1)上工作,虽然有时它会失败,所以我的代码在弹出“地理编码器错误”Toast之前尝试了两次。

答案 1 :(得分:0)

确保使用正确的API KEY ...按照此处的说明操作:

http://code.google.com/android/add-ons/google-apis/mapkey.html

请注意,调试测试版本使用debug.keystore,因此请确保为其创建密钥...而不是在生产中。