Last month of so geocoder has started to fail every time with \"grpc failed\" error and I can\'t seem to be able to solve it. I\'ve looked at java.io.IOException: grpc failed bu
Well, this might be too late and for someone else looking for answers, in my case it was internet problem. My internet connection was bad
The problem may be that you are trying to use Geocoder in the main thread, if you are using an IntentService you have this URL option to create in another process although you can always use an Asynctask or similar.
It's related to Google Play Service on virtual devices. Use API25 and version 7.1.1 for solution.
Here are examples;
When I try on Genymotion and Google Play Services is disabled on virtual device (Error: Service not Available):
10-07 07:13:30.023 3481-3481/com.unalfaruk.mapexample I/System.out: Your Location: 65.96992333333333 -18.540028333333332
10-07 07:13:30.023 3481-3481/com.unalfaruk.mapexample W/System.err: java.io.IOException: Service not Available
10-07 07:13:30.024 3481-3481/com.unalfaruk.mapexample W/System.err: at android.location.Geocoder.getFromLocation(Geocoder.java:136)
10-07 07:13:30.024 3481-3481/com.unalfaruk.mapexample W/System.err: at com.unalfaruk.mapexample.MapsActivity$1.onLocationChanged(MapsActivity.java:71)
10-07 07:13:30.024 3481-3481/com.unalfaruk.mapexample W/System.err: at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:297)
When I try on Genymotion and Google Play Services is enabled (Error: grpc failed):
10-07 07:18:56.325 2694-2694/com.unalfaruk.mapexample I/System.out: Your Location: 65.96669666666666 -15.0
10-07 07:18:57.670 2694-2694/com.unalfaruk.mapexample W/System.err: java.io.IOException: grpc failed
10-07 07:18:57.670 2694-2694/com.unalfaruk.mapexample W/System.err: at android.location.Geocoder.getFromLocation(Geocoder.java:136)
10-07 07:18:57.670 2694-2694/com.unalfaruk.mapexample W/System.err: at com.unalfaruk.mapexample.MapsActivity$1.onLocationChanged(MapsActivity.java:71)
10-07 07:18:57.670 2694-2694/com.unalfaruk.mapexample W/System.err: at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:297)
When I try on AVD Manager and Google Play Services is enabled (No error):
10-07 14:20:14.769 3159-3159/com.unalfaruk.mapexample I/System.out: Your Location: 37.421998333333335 -122.08400000000002
10-07 14:20:15.220 3159-3159/com.unalfaruk.mapexample I/System.out: Your Adress: Address[addressLines=[0:"1600 Amphitheatre Parkway",1:"Mountain View, CA 94043",2:"USA"],feature=1600,admin=California,sub-admin=null,locality=Mountain View,thoroughfare=Amphitheatre Parkway,postalCode=94043,countryCode=US,countryName=United States,hasLatitude=true,latitude=37.422329,hasLongitude=true,longitude=-122.0843055,phone=null,url=null,extras=null]