Geocoder grpc失败了 [英] Geocoder grpc failed

查看:694
本文介绍了Geocoder grpc失败了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上个月,地理编码器每次因grpc失败错误而开始失败,我似乎无法解决它。我看过 java.io.IOException:grpc失败但它没有真的解决了这个问题。

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.

例如代码

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.

如果我针对SDK 25进行编译,使用构建工具25它可以工作使用SDK 25的模拟器。但是如果我尝试使用SDK 24,26或任何其他SDK版本的模拟器,它将失败并显示grpc failed。我试图创建一个新的虚拟设备等同样的问题。

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.

当前设置:targetSDK / compileSDK 25,构建工具25.0.3,Android Studio 2.3.3,常规模拟器。 (我已经尝试过其他构建工具和SDK版本,但问题仍然存在)

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)

任何想法?

推荐答案

问题可能是您尝试在主线程中使用Geocoder,如果您使用的是IntentService,那么 URL 选项可在另一个进程中创建,但您始终可以使用Asynctask或类似的。

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.

这篇关于Geocoder grpc失败了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆