Geocoder.getFromLocation grpc 在安卓真机上失败 [英] Geocoder.getFromLocation grpc failed on Android real device

查看:68
本文介绍了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 failed 中建议的堆栈溢出但对我不起作用.

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 问题跟踪器中针对真实设备和模拟器报告的持续问题.可以参考以下bug:

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.

作为一种解决方法,您可以考虑使用地理编码 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 地理编码器时遇到的错误.

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/

我希望这会有所帮助!

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

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