android Geocoder throws IOException: Service not Available - android

after removing firebase analytics, ads and crashlytics (and google-services.json), I get the following error:
java.io.IOException: Service not Available
Code:
Geocoder gcd = new Geocoder(context, Locale.getDefault());
final List<Address> addresses = gcd.getFromLocation(latlng.latitude, latlng.longitude, 1);
I don't find any explanation why this happens... Anyone here who can help me?
There is no APIKey to appy or something, right?
PS: My maps fragment is working (com.google.android.geo.API_KEY meta-data in manifest is used)
I'm running OnePlus One, Android 8.1.0 (aosp_bacon-8.1.0-20180331.agentfabulous) and gapps mini.

Seems to be a problem with my phone. I will implement this.
I'm going to close this thread.

Yes u need geocoding api key:
When i used have same problem my solution was restart phone but from reserch then i found couple solution about that.
Recreate api key
Api key get limit or bugeed
Use other for check is it blame of full service or not
Move one part to other project and check does it work if yes that meen it's problem in code somew here

Related

Unexpected grpc failed using geocoder

Following the line of code throwing: grpc failed error yesterday.but today it's working fine.
List<Address> addresses=geocoder.getFromLocation(location.getLatitude(),location.getLongitude(),1);
can somebody please explain?
It looks like native Geocoder of Android API periodically experiences this issue. It was reported to Google some time ago, but looks like the issue wasn't solved definitely:
https://issuetracker.google.com/issues/64418751
Feel free to star this bug to add your vote.
As an alternative you can consider switching to Geocoding API web service that seems to be more reliable. You can use the Java client library for Google Maps API Web Services to implement web service calls from your Android app:
https://github.com/googlemaps/google-maps-services-java
This library has reverse geocoding function similar to getFromLocation. Check the javadoc for more details:
https://googlemaps.github.io/google-maps-services-java/v0.2.5/javadoc/
I hope this helps!

Android: Automatic User Locatio

I am working on the developement of an android app. I need to locate the user without displaying the map (only the name of his location ei New york, USA)
I work using Eclipse SDK.
Is there a way to do it?
Thanks :)
Ps: I am new to android
Android API Maps
In the API documentation it shows you step by step how to get started on this
type of application.
How to get started
One thing you have to remember is that the user must enable
the GPS to get current location
Since you explained in comments that you already know how to get the Location, and thus the latitude and longitude, you can resolve it to an address using Android's GeoCoder class, with its getFromLocation(double,double,int) method.

Geocoder.getFromLocation() returns addresses in arabic

Im using Geocoder on Android devices from Israel. Up until a few weeks ago everything worked fine and when i was doing reverse geocoding all addresses were received in hebrew. But at some point i started getting the same addresses in arabic.
This is a sample code im running (the lat/lon is in Tel-Aviv) :
Geocoder geocoder = new Geocoder(mContext, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(32.087765863162346, 34.781454205513, 1);
When i inspect 'addresses' i get the following printout :
[Address[addressLines=[0:"عمنوئيل هرومي 26",1:"Tel Aviv",2:"Israel"],feature=26,admin=null,sub-admin=null,locality=Tel Aviv,thoroughfare=عمنوئيل هرومي,postalCode=null,countryCode=IL,countryName=Israel,hasLatitude=true,latitude=32.0877767,hasLongitude=true,longitude=34.7813859,phone=null,url=null,extras=null]]
Please note that the devices are not localized to israel. meaning, Locale.getDefault() has "US" and "en" as country and language codes.
I already opened a bug in the Geocoder issue tracker - http://code.google.com/p/gmaps-api-issues/issues/detail?id=6182 - but was referred to the Android issue tracker. Opened another one over there - https://code.google.com/p/android/issues/detail?id=64382 - but it seems like the bug is not even in the android device side but in the Geocoder backend service. So im in a dead end.
I'd appreciate if anybody that knows anybody that knows someone from the responsible team in Google will let them know. Thanks.
EDIT: since i sense that questions posted here that are not exactly formed as questions are not very appreciated, let me rephrase - Does anyone know an issue tracker where its possible to open an issue regarding the android Geocoder backend service ? Again, thanks.
I had the same problem and I fixed it by setting a Locale in the Geocoder init,
you can do something like this:
Locale lHebrew = new Locale("he");
Geocoder geocoder = new Geocoder(this, lHebrew);
Let me know if the problem has been solved.

Android Geocoder doesn't detect highways / interstates?

I'm using getThoroughwayfare() to get street names but when on a highway / interstate the method returns null. I couldn't find another method that could detect interstates. Has anyone been able to successfully detected interstates?
Thanks
Ok, Its quite old question, but i think i answer for somebody else.
I too need to get information whether i was on interstate or not and Geocoder was of no help.
So i came across Google geocode api which gives plenty of information.
e.g
LatLng: 39.249121,-122.182131
And Url would be:
https://maps.googleapis.com/maps/api/geocode/json?latlng=39.249121,-122.182131&sensor=false
sensor is true in case you sending from mobile and false if using browser.
Now you can open the link and check the detailed reply for yourself, in those json objects, you will get a type = route and you will get I-5 as the short_name of road you are on.

Android Geocoder - different results when called from different geographical locations

I have the following code in my Android program
List<Address> addressList = geoCoder.getFromLocation(37.790551,-122.433931, 1);
if (!addressList.isEmpty()) {
address = addressList.get(0);
String number = address.getSubThoroughfare();
String streetName = address.getThoroughfare();
.....
}
This is a request to essentially get a street name (hence the 1) from a latitude and longitude in San Francisco.
When I execute this program on a phone in Europe (specifically Ireland) number is returned as 2250-2290 and streetname is returned as Fillmore St.
When I get a friend to run the same code on his phone in California number is null and streetname is still Fillmore st.
I've seen other SO questions allude to region settings but is this possible that the geographical location can affect the query in the Android API?
The Javascript Geocoding API mentions region bias. I wonder is it possible to do something similar in the Android API. I did try creating the Geocoder as
Geocoder geoCoder = new Geocoder(getApplicationContext(), Locale.US);
but this does not re-recreate the California based result.
From getting people to run identical code on different continents it seems that location is indeed a factor.
The Javascript geocoding allows you to specify a region though
Are the phones running different versions of android? Also, another thing to keep in mind is that "The Geocoder class requires a backend service that is not included in the core android framework." So, if the two phones are calling upon different backend services to query for the Geocoder, that may explain the output you are seeing.
I think with Android 1.5, they included a Google API backend service implementation for Geocoder. I don't know if newer versions of Android and the Google API made changes to the Geocoder implementation that may be giving you different results or it's coming from some other backend service.

Categories

Resources