Working on a project that gets the address from a database.
From those addresses i get the LatLng and pin them on a Google maps Activity.
I use this method to get LatLng from the address :
public LatLng getLocationFromAddress(Context context, String inputtedAddress) {
Geocoder coder = new Geocoder(context);
List<Address> address;
LatLng resLatLng = null;
try {
// May throw an IOException
address = coder.getFromLocationName(inputtedAddress, 5);
if (address == null) {
return null;
}
if (address.size() == 0) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
resLatLng = new LatLng(location.getLatitude(), location.getLongitude());
} catch (IOException ex) {
ex.printStackTrace();
}
return resLatLng;
Until 2 days ago, it gave me 164 correct coordenates from 285 addresses. Some of the addresses gave LatLng null for some reason.
Without changing any code, now i get the following error for the first 8-10 calls to the geocoder :
W/System.err: java.io.IOException: Timed out waiting for response from server
W/System.err: at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
After that, the rest give this error:
W/System.err: java.io.IOException: RPC failed with status 102
at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
The exact line that gives the error is :
address = coder.getFromLocationName(inputtedAddress, 5);
EDIT:
After some more investigating i've found out that the Geocoder.java class has errors, missing some methods:
Would reinstalling Android Studio Work?
It seems that the emulator didnt have an internet connection. Changing From Ethernet to WiFi resolved the issue. While on Ethernet, the DNS was the domain one, so it couldnt connect to the Internet for some reason.