无法解析主机。没有与主机名关联的地址

时间:2020-06-07 12:35:58

标签: android networking connection wifi hostname

我正在尝试将移动应用程序与桌面应用程序连接起来,但这对我来说是不可能的。 这两台设备都连接到同一个wifi,并且清单上有互联网设备。

清单后清单

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

enter image description here

错误

I/System.out: Unable to resolve host "JarsUbuntuComputer": No address associated with hostname

1 个答案:

答案 0 :(得分:0)

在JarsUbuntuComputer的位置输入您计算机的IP地址,并确保端口号相同或不相同

还将其添加到“清单”的“应用程序”标记中

android:usesCleartextTraffic="true"
android:allowClearUserData="true"

完整代码

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    android:allowClearUserData="true">
    <activity android:name=".MainActivity"></activity>
相关问题