暂无图片
用android studio连接阿里云mysql一直连不上,日志报错:NetworkSecurityConfig: No Network Security Config specified, using platform default
我来答
分享
刺史武都
2021-08-31
用android studio连接阿里云mysql一直连不上,日志报错:NetworkSecurityConfig: No Network Security Config specified, using platform default

c1652e780cbf3119d637c89ada9d700.png
0f90ecec812a9950acd927bfdd16c24.png

我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
三笠丶
暂无图片

原因:

这是因为Android9.0之后默认使用https访问网络,所以你需要配置一个这样的文件,更重要的配置之后你要在AndroidManifest.xml的application标签中使用才行,否则等于没有配。

解决方案:

在app/src/main/AndroidManifest.xml中的<application标记中添加android:networkSecurityConfig="@xml/network_security_config":

<application android:name=".ApplicationClass" android:allowBackup="true" android:hardwareAccelerated="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:largeHeap="true" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:theme="@style/AppTheme">

image.png

在app/src/main/res/xml/中带有相应的network_security_config.xml:

<?xml version="1.0" encoding="utf-8"?> <network-security-config> <base-config cleartextTrafficPermitted="true" /> </network-security-config>

希望能帮助到你!

暂无图片 评论
暂无图片 有用 0
暂无图片
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏