46

I have a little problem with the geocoder to get latitude and lontitude from an address :

This is my code:

for (Garage g : XMLGarage) { List<Address> address; address = coder.getFromLocationName( g.getAddress(), 5); if (address != null) { Address location = address.get(0); g.setLatitude(location.getLatitude()); g.setLongitude(location.getLongitude()); ... 

The error is :

08-18 14:28:56.026: WARN/System.err(359): java.io.IOException: Service not Available 08-18 14:28:56.026: WARN/System.err(359): at android.location.Geocoder.getFromLocationName(Geocoder.java:178) 08-18 14:28:56.026: WARN/System.err(359): at com.amt.android.garage.Garage.postData(Garage.java:269) 08-18 14:28:56.026: WARN/System.err(359): at com.amt.android.garage.GarageForm$2.onClick(GarageForm.java:86) 08-18 14:28:56.026: WARN/System.err(359): at android.view.View.performClick(View.java:2485) 08-18 14:28:56.026: WARN/System.err(359): at android.view.View$PerformClick.run(View.java:9080) 08-18 14:28:56.036: WARN/System.err(359): at android.os.Handler.handleCallback(Handler.java:587) 08-18 14:28:56.036: WARN/System.err(359): at android.os.Handler.dispatchMessage(Handler.java:92) 08-18 14:28:56.036: WARN/System.err(359): at android.os.Looper.loop(Looper.java:130) 08-18 14:28:56.036: WARN/System.err(359): at android.app.ActivityThread.main(ActivityThread.java:3683) 08-18 14:28:56.036: WARN/System.err(359): at java.lang.reflect.Method.invokeNative(Native Method) 08-18 14:28:56.036: WARN/System.err(359): at java.lang.reflect.Method.invoke(Method.java:507) 08-18 14:28:56.036: WARN/System.err(359): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 08-18 14:28:56.046: WARN/System.err(359): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 08-18 14:28:56.046: WARN/System.err(359): at dalvik.system.NativeStart.main(Native Method) 
2
  • I'd like to point out that even though this question is marked as a duplicate (which is correct), the top answer given on this question is a valid, possible solution that the other question does not offer. Commented Apr 16, 2013 at 16:07
  • Please reboot your device first, it might be enough to fix your problem. Commented Mar 17, 2018 at 19:05

3 Answers 3

100

There is a problem recently with android devices and the geocoder not working: http://code.google.com/p/android/issues/detail?id=38009

A reboot seems to fix the issue

Sign up to request clarification or add additional context in comments.

14 Comments

suggesting a reboot is a terrible solution. Even more terrible of a solution when it's the correct one. Worked for me.
Had this problem with 2 tablets. Upgraded with Google play services and Geocoder did not work. Reboot fixxed the issue. Come on google...
OK.. I just try to edit the post but my edit was rejected. I just want to share my experience: rebooting fix the problem just.. temporary. The bug comes back again. As an alternative, one can use Google Map API. I made a full working example availalbe here: stackoverflow.com/questions/9272918/…
i think this is a silly solution, but it's worked!
@RichardLeMesurier 2017 here... it can still happen with an API 25 target
|
13

You will get this error occasionally if the GeoCoding provider fails and is unable to geocode your location.

See these relevant posts:

Geocoder.getFromLocation throws Exception

Geocoder.getFromLocation throws IOException on Android emulator

If this is not the case, make sure you have the Internet permission in your Manifest:

<uses-permission android:name="android.permission.INTERNET" /> 

1 Comment

Service not Available - Geocoder Android when i get this error in some cooked roms i wrote this library i hope could be useful. github.com/dnocode/gapis
0

Try updating Location first. Like below

locationManager.requestLocationUpdates(bestProvider, 20000, 1, this); 

refer to here.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.