Android真实设备上的Geocoder.getFromLocation grpc失败 [英] Geocoder.getFromLocation grpc failed on Android real device

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

问题描述

我需要从经度和纬度中得出城市和州. Geocoder会执行此功能以获取城市和州.但是仅在 Android真实设备上,我在下面的行中收到错误java.io.IOException: grpc failed.在 模拟器 中正常运行.

I need to get the city and state from latitude and longitude. Geocoder does this function to get the city and state. But I am getting an error java.io.IOException: grpc failed in below line only on Android real device. It is working fine in emulators.

new Geocoder(context).getFromLocation(latLng.latitude, latLng.longitude, 1).get(0);

我也一直在使用Asynctask调用此函数,这在另一篇文章 Geocoder grpc失败中建议堆栈溢出,但对我没有任何作用.

Also I have been calling this function using Asynctask which is suggested in another post Geocoder grpc failed in stack overflow but nothing works for me.

我也重新启动了设备,但仍然失败.

And I have restart the device as well but still it is failing.

此处需要帮助.预先感谢.

Help needed here. Thanks in advance.

注意:我在Google Pixel XL,Samsung S6 edge和Samsung S4中进行了测试.

Note: I tested in Google Pixel XL, Samsung S6 edge, Samsung S4.

推荐答案

这似乎是一个持续存在的问题,已在Google问题跟踪器中针对实际设备和仿真器进行了报告.您可以参考以下错误:

It looks like this is ongoing issue that was reported in the Google issue tracker both for real devices and emulators. You can refer to the following bugs:

https://issuetracker.google.com/issues/64418751

https://issuetracker.google.com/issues/64247769

不幸的是,Google尚未解决这些问题.

Unfortunately, Google haven't solved these issues yet.

作为解决方法,您可以考虑使用Geocoding API网络服务.请注意,您可以在Github上找到用于Web服务的Java客户端库:

As a workaround you can consider using the Geocoding API web service. Please note that there is a Java client library for web services that you can find on Github:

https://github.com/googlemaps/google-maps-services-java

使用Java客户端库用于Web服务,您可以实现反向地理编码查找,而该反向地理编码查找不会给您带来本机Android Geocoder遇到的错误.

Using Java client library for web services you can implement reverse geocoding lookup that shouldn't give you the error that you experience with native Android geocoder.

客户端库的Javadoc位于

The Javadoc for client library is located at

https://googlemaps.github.io/google -maps-services-java/v0.2.5/javadoc/

我希望这会有所帮助!

I hope this helps!

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

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