Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geocoder grpc failed

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 but it didn't really solve the problem.

For exampel the code

Geocoder geocoder = new Geocoder(context, Locale.getDefault());
addresses = geocoder.getFromLocation(lat, lng, 1); // Here if fails with "grpc failed"

I've had the same code for years, but it's just lately it has stopped working when I recompile the app and test on an emulator or real device.

If I compile against SDK 25, using build tool 25 it works on an emulator with SDK 25. But if I try on an emulator with SDK 24, 26 or any other SDK version, it will fail with "grpc failed". I've tried to create a new virtual device etc. but same problem.

I have no clue how to fix it and what the problem is.

Current setup: targetSDK/compileSDK 25, build tool 25.0.3, Android Studio 2.3.3, regular emulator. (I've tried other build tools and SDK versions, but problem still remains)

Any ideas?

like image 647
Mackan Avatar asked Aug 05 '17 11:08

Mackan


2 Answers

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.

like image 94
Cifus Avatar answered Oct 15 '22 03:10

Cifus


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

like image 25
user7764270 Avatar answered Oct 15 '22 01:10

user7764270