Android/Kotlin 教程的 gRPC 快速入门 - 服务器响应中不可用

问题描述

gRPC Quick start for Android/Kotlin 之后,我成功地在我的 PC 上构建和运行了服务器,并安装了 Android 应用程序(在本地网络中通过 TCP 与 adb 连接,同一子网,PC 防火墙关闭)。>

但是在运行应用程序时,输入例如“Alice”并点击 SEND GRPC REQUEST,我在 UNAVAILABLE 得到 Server response。服务器正在运行,监听50051端口。

我有一个功能齐全的连接:运行时,例如python3 -m http.server 在我的 PC 上,我可以毫无问题地从我的 android 设备访问它。

我觉得奇怪的一件事是,该教程中没有提到在客户端代码/应用程序中指定服务器的 IP 地址。

我错过了什么?

解决方法

为了指定服务器的IP地址,我们需要添加-PserverUrl=http://xxx.xxx.xxx.xxx:50051

.\gradlew :android:installDebug -PserverUrl=http://xxx.xxx.xxx.xxx:50051