问题描述
当我使用 call getFromLocationName 时,我收到了一个 IOException,描述为grpc failed".
When I use call getFromLocationName I get an IOException with description "grpc failed".
运行的代码
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
try {
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
List<Address> listAdresses = geocoder.getFromLocationName("London", 10);
Log.i("PlaceInfo", listAdresses.get(0).toString());
} catch (IOException e) {
e.printStackTrace();
}
}
控制台输出错误:
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: java.io.IOException: grpc failed
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at co.siqve.maplocationdemo.MapsActivity.onMapReady(MapsActivity.java:70)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at com.google.android.gms.maps.zzaj.zza(Unknown Source)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at com.google.android.gms.maps.internal.zzaq.onTransact(Unknown Source)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at android.os.Binder.transact(Binder.java:499)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at com.google.android.gms.maps.internal.aq.a(:com.google.android.gms.DynamiteModulesB:5)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at com.google.maps.api.android.lib6.impl.bb.run(:com.google.android.gms.DynamiteModulesB:5)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at android.os.Handler.handleCallback(Handler.java:751)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at android.os.Looper.loop(Looper.java:154)
07-10 12:01:38.781 13712-13712/co.siqve.maplocationdemo W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6119)
07-10 12:01:38.782 13712-13712/co.siqve.maplocationdemo W/System.err: at java.lang.reflect.Method.invoke(Native Method)
07-10 12:01:38.782 13712-13712/co.siqve.maplocationdemo W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
07-10 12:01:38.782 13712-13712/co.siqve.maplocationdemo W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Android SDK 版本(API 级别):25
Android SDK Version (API Level): 25
Android Studio 插件是最新的.
Android Studio plugins are up to date.
提前致谢!
问题现在似乎已解决,这是我的解决方案.
Problem seems to be fixed now, here is my solution.
推荐答案
更新:
问题现在似乎已经解决了.我不确定是不是我的问题出在我的身上,所以如果你在这篇文章之前遇到过这个问题,请重新运行你的应用,看看它现在是否有效.
The problem seems to be solved now. I'm not sure if it the problem ever was on my end, so if you had this problem prior to this post, re-run your app and see if it works now.
如果它仍然不起作用,这是我自己做的可能"使它起作用的东西:
If it still doesn't work, here is the stuff I did myself that "might" have made it work:
- 我卸载并删除了与 Android Studio 相关的所有文件.(不是项目文件).
- 然后我重新安装了 Android Studio,并重新打开了项目备份.
- 在运行应用程序时(我使用的是 Android Studio 的内置模拟器),我使用了不同的虚拟设备和设备 API.这次我在 Pixel 上运行它,使用 API 23,x86_64.
这篇关于java.io.IOException: grpc 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!