处理从数据库获取地址的项目。
从这些地址,我得到了LatLng,并将其钉在谷歌地图活动上。
我使用此方法从地址获取LatLng:
public LatLng getLocationFromAddress(Context context, String inputtedAddress) {
Geocoder coder = new Geocoder(context);
List<Address> address;
LatLng resLatLng = null;
try {
// May throw an IOException
address = coder.getFromLocationName(inputtedAddress, 5);
if (address == null) {
return null;
}
if (address.size() == 0) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
resLatLng = new LatLng(location.getLatitude(), location.getLongitude());
} catch (IOException ex) {
ex.printStackTrace();
}
return resLatLng;直到两天前,它给了我来自285个地址的164个正确的坐标。某些地址出于某种原因使LatLng为null。
在不更改任何代码的情况下,现在我得到了对Geo编码器的前8-10次调用的以下错误:
W/System.err: java.io.IOException: Timed out waiting for response from server
W/System.err: at android.location.Geocoder.getFromLocationName(Geocoder.java:178)在此之后,其余部分将给出以下错误:
W/System.err: java.io.IOException: RPC failed with status 102
at android.location.Geocoder.getFromLocationName(Geocoder.java:178)给出错误的确切行是:
address = coder.getFromLocationName(inputtedAddress, 5);编辑:
经过进一步的调查,我发现Geocoder.java类存在错误,缺少了一些方法:

重新安装Android有效吗?
发布于 2018-04-03 11:27:15
仿真器似乎没有互联网连接。从以太网到WiFi的转变解决了这个问题。在以太网上,DNS是域域,因此由于某种原因无法连接到Internet。
发布于 2018-03-29 10:20:40
这个问题已在https://stackoverflow.com/a/46256093/20394中得到解决。
解决方案是升级Google服务以修改44+。
https://stackoverflow.com/questions/49553479
复制相似问题