为什么华为p20手机真机测试时连不了网,获取不了json数据

图片说明图片说明图片说明图片说明

https://jingyan.baidu.com/article/48a420571c3e73a92425042f.html

手机的网络和服务端的网络在不在一个网段

载入应用后,查看下访问权限,是否网络允许访问。

确认SDK目标版本是28?如果是28版本,则按以下方法处理
1.在AndroidManifest.xml中增加android:networkSecurityConfig="@xml/network_security_config"
android:label="@string/app_name"
android:allowBackup="true"
android:networkSecurityConfig="@xml/network_security_config"
android:icon="@mipmap/ic_launcher">
2.在res/xml增加network_security_config.xml档案,内容如下