When I use call getFromLocationName I get an IOException with description \"grpc failed\".
Code that\'s ran
@Override
public void onMapReady(GoogleMa
Although pretty late on the issue, here is an answer for Kotlin users.
I stumbled upon this java.io.IOException: grpc failed error whilst using Geocoder's getFromLocation function. I have been using a Google Pixel 2 as my test device (running Android 9).
There are 3 things to make sure of:
Geocoder needs to be done apart from the main thread of your app.
To support my claim, here is a quote from the Android documentation: "The method is synchronous and may take a long time to do its work, so you should not call it from the main, user interface (UI) thread of your app."Now, it is best to use IntentService for this task like the official documentation has given an example of. However, this person tried it with an AsyncTask in Java and it worked just fine (note that their task with geocoder was a lot less intensive). Therefore, I highly recommend using Anko's doAsync method and implement any code regarding Geocoder within it.
If possible, use a physical device instead of an emulator. The emulator on Android Studio gave me a lot of trouble and was not giving me the error information I needed to really debug the problem.
Reinstall your app on your physical device and Invalidate Caches/Restart your project several times.
Also make sure you have good network connection and it is enabled on your device.