Why is Android Geocoder throwing a "Service not Available" exception?

Ollie C picture Ollie C · Jan 21, 2011 · Viewed 23.3k times · Source

The app uses the Geocoder object. It works fine on my stock Froyo Nexus One. But then I run the exact same app on a different device (an Advent Vega 10" tablet also running Froyo) and I get this exception: Service not Available. The method I'm using is getFromLocationName(), I'm building against the Android 1.6 Google API.

I'm aware of an issue where this exception is thrown on the emulator, but I suspect this is different. Why would it be thrown on one device running Froyo but not another?

The app is a location app, and as the tablet has no GPS or mobile network, in a scenario where the Wi-Fi connection doesn't provide a location, the user must manually specify it, so not being able to use the Geocoder object is bad news.

I could add a way for the user to select the location on a map, but it's not ideal. Possibly I could use the Google Maps API directly, but I'm keen to understand the nature of the issue first as would be nice to have an easier solution.

Hopefully in a future release Android will include an OS-level "default location" for non-Geocoder devices, so location-aware apps work out of the box on devices like Google TV.

Answer

Ollie C picture Ollie C · Jan 21, 2011

I asked Google's Reto Meier to confirm my theory was correct and he said "Correct. The Geocoder is part of the Google API add-on that isn't part of the AOSP."

So any device that doesn't come with the Play Store, GMail apps etc… will also be missing the Geocoder back-end.